Skip to content

Commit 67a93b5

Browse files
author
Alex Bush
committed
2 parents 31cdbdc + a82e3ec commit 67a93b5

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

zeppelin-web/src/app/tabledata/pivot.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default class PivotTransformation extends Transformation {
8989
for (let j = i + 1; j < list.length; j++) {
9090
if (angular.equals(list[i], list[j])) {
9191
list.splice(j, 1)
92+
j--
9293
}
9394
}
9495
}

zeppelin-web/src/app/tabledata/tabledata.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
import TableData from './tabledata.js'
16+
import PivotTransformation from './pivot.js'
1617

1718
describe('TableData build', function () {
1819
let td
@@ -39,3 +40,47 @@ describe('TableData build', function () {
3940
expect(td.comment).toBe('hello')
4041
})
4142
})
43+
44+
describe('PivotTransformation build', function() {
45+
let pt
46+
47+
beforeEach(function () {
48+
console.log(PivotTransformation)
49+
pt = new PivotTransformation()
50+
})
51+
52+
it('check the result of keys, groups and values unique', function() {
53+
// set inited mock data
54+
let config = {
55+
common: {
56+
pivot: {
57+
keys: [{index: 4, name: '4'},
58+
{index: 3, name: '3'},
59+
{index: 4, name: '4'},
60+
{index: 3, name: '3'},
61+
{index: 3, name: '3'},
62+
{index: 3, name: '3'},
63+
{index: 3, name: '3'},
64+
{index: 5, name: '5'}],
65+
groups: [],
66+
values: []
67+
}
68+
}
69+
}
70+
pt.tableDataColumns = [
71+
{index: 1, name: '1'},
72+
{index: 2, name: '2'},
73+
{index: 3, name: '3'},
74+
{index: 4, name: '4'},
75+
{index: 5, name: '5'}]
76+
77+
pt.setConfig(config)
78+
79+
pt.removeUnknown()
80+
81+
expect(config.common.pivot.keys.length).toBe(3)
82+
expect(config.common.pivot.keys[0].index).toBe(4)
83+
expect(config.common.pivot.keys[1].index).toBe(3)
84+
expect(config.common.pivot.keys[2].index).toBe(5)
85+
})
86+
})

0 commit comments

Comments
 (0)