Skip to content

Commit

Permalink
add test cases for valueConsistsOf prop
Browse files Browse the repository at this point in the history
  • Loading branch information
riophae committed Mar 29, 2018
1 parent 92af4df commit 557a2ac
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions test/unit/specs/Treeselect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4394,6 +4394,78 @@ describe('Props', () => {
})
})

describe('valueConsistsOf', () => {
let wrapper, vm

beforeEach(() => {
wrapper = mount(Treeselect, {
propsData: {
multiple: true,
options: [ {
id: 'a',
label: 'a',
children: [ {
id: 'aa',
label: 'aa',
children: [ {
id: 'aaa',
label: 'aaa',
}, {
id: 'aab',
label: 'aab',
} ],
}, {
id: 'ab',
label: 'ab',
children: [ {
id: 'aba',
label: 'aba',
}, {
id: 'abb',
label: 'abb',
} ],
}, {
id: 'ac',
label: 'ac',
} ],
} ],
value: [ 'aa' ],
},
})
vm = wrapper.vm
})

it('when valueConsistsOf=ALL', () => {
wrapper.setProps({ valueConsistsOf: 'ALL' })

expect(vm.internalValue).toEqual([ 'aa', 'aaa', 'aab' ])
vm.select(vm.nodeMap.ab)
expect(vm.internalValue).toEqual([ 'aa', 'aaa', 'aab', 'ab', 'aba', 'abb' ])
vm.select(vm.nodeMap.ac)
expect(vm.internalValue).toEqual([ 'aa', 'aaa', 'aab', 'ab', 'aba', 'abb', 'ac', 'a' ])
})

it('when valueConsistsOf=BRANCH_PRIORITY', () => {
wrapper.setProps({ valueConsistsOf: 'BRANCH_PRIORITY' })

expect(vm.internalValue).toEqual([ 'aa' ])
vm.select(vm.nodeMap.ab)
expect(vm.internalValue).toEqual([ 'aa', 'ab' ])
vm.select(vm.nodeMap.ac)
expect(vm.internalValue).toEqual([ 'a' ])
})

it('when valueConsistsOf=LEAF_PRIORITY', () => {
wrapper.setProps({ valueConsistsOf: 'LEAF_PRIORITY' })

expect(vm.internalValue).toEqual([ 'aaa', 'aab' ])
vm.select(vm.nodeMap.ab)
expect(vm.internalValue).toEqual([ 'aaa', 'aab', 'aba', 'abb' ])
vm.select(vm.nodeMap.ac)
expect(vm.internalValue).toEqual([ 'aaa', 'aab', 'aba', 'abb', 'ac' ])
})
})

describe('valueFormat', () => {
describe('when valueFormat=id', () => {
it('single-select', async done => {
Expand Down

0 comments on commit 557a2ac

Please sign in to comment.