mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-01 13:36:55 +08:00
test(select): add some test case for v-model
Select's view should sync with initial value and equal '' when v-model is null
This commit is contained in:
parent
99e70c8e9e
commit
9042b21c24
@ -399,15 +399,16 @@ describe('Select', function () {
|
||||
data () {
|
||||
return {
|
||||
items: _.cloneDeep(items),
|
||||
selectedValue: null
|
||||
selectedValue: 'value1'
|
||||
}
|
||||
}
|
||||
}
|
||||
const wrapper = mount(NSelectTestContext)
|
||||
wrapper.vm.selectedValue = 'value1'
|
||||
expect(wrapper.find('input').element.value).to.contain('label1')
|
||||
wrapper.vm.selectedValue = 'value2'
|
||||
expect(wrapper.find('input').element.value).to.contain('label2')
|
||||
wrapper.vm.selectedValue = null
|
||||
expect(wrapper.find('input').element.value).to.equal('')
|
||||
})
|
||||
it('should sync value with view', function () {
|
||||
const NSelectTestContext = {
|
||||
@ -478,12 +479,11 @@ describe('Select', function () {
|
||||
data () {
|
||||
return {
|
||||
items: _.cloneDeep(items),
|
||||
selectedArray: []
|
||||
selectedArray: ['value1']
|
||||
}
|
||||
}
|
||||
}
|
||||
const wrapper = mount(NSelectTestContext)
|
||||
wrapper.vm.selectedArray.push('value1')
|
||||
expect(wrapper.html()).to.contain('label1')
|
||||
wrapper.vm.selectedArray.push('value2')
|
||||
expect(wrapper.html()).to.contain('label1', 'label2')
|
||||
|
Loading…
Reference in New Issue
Block a user