Merge branch 'master' into ZEPPELIN-3091

This commit is contained in:
Naman Mishra 2017-12-11 14:39:38 +05:30
commit 38ad39c657
2 changed files with 46 additions and 0 deletions

View file

@ -89,6 +89,7 @@ export default class PivotTransformation extends Transformation {
for (let j = i + 1; j < list.length; j++) {
if (angular.equals(list[i], list[j])) {
list.splice(j, 1)
j--
}
}
}

View file

@ -13,6 +13,7 @@
*/
import TableData from './tabledata.js'
import PivotTransformation from './pivot.js'
describe('TableData build', function () {
let td
@ -39,3 +40,47 @@ describe('TableData build', function () {
expect(td.comment).toBe('hello')
})
})
describe('PivotTransformation build', function() {
let pt
beforeEach(function () {
console.log(PivotTransformation)
pt = new PivotTransformation()
})
it('check the result of keys, groups and values unique', function() {
// set inited mock data
let config = {
common: {
pivot: {
keys: [{index: 4, name: '4'},
{index: 3, name: '3'},
{index: 4, name: '4'},
{index: 3, name: '3'},
{index: 3, name: '3'},
{index: 3, name: '3'},
{index: 3, name: '3'},
{index: 5, name: '5'}],
groups: [],
values: []
}
}
}
pt.tableDataColumns = [
{index: 1, name: '1'},
{index: 2, name: '2'},
{index: 3, name: '3'},
{index: 4, name: '4'},
{index: 5, name: '5'}]
pt.setConfig(config)
pt.removeUnknown()
expect(config.common.pivot.keys.length).toBe(3)
expect(config.common.pivot.keys[0].index).toBe(4)
expect(config.common.pivot.keys[1].index).toBe(3)
expect(config.common.pivot.keys[2].index).toBe(5)
})
})