mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
Add tests
This commit is contained in:
@@ -1222,4 +1222,47 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe( 'Clear button', () => {
|
||||||
|
|
||||||
|
it( 'should display clear button on single select with a selected value', () => {
|
||||||
|
const VueSelect = Vue.extend( vSelect )
|
||||||
|
const vm = new VueSelect({
|
||||||
|
propsData: {
|
||||||
|
options: ['foo','bar'],
|
||||||
|
value: 'foo'
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
expect(vm.showClearButton).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it( 'should not display clear button on multiple select', () => {
|
||||||
|
const VueSelect = Vue.extend( vSelect )
|
||||||
|
const vm = new VueSelect({
|
||||||
|
propsData: {
|
||||||
|
options: ['foo','bar'],
|
||||||
|
value: 'foo',
|
||||||
|
multiple: true
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
expect(vm.showClearButton).toEqual(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it( 'should remove selected value when clear button is clicked', () => {
|
||||||
|
const VueSelect = Vue.extend( vSelect )
|
||||||
|
const vm = new VueSelect({
|
||||||
|
propsData: {
|
||||||
|
options: ['foo','bar'],
|
||||||
|
value: 'foo'
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
expect(vm.mutableValue).toEqual('foo')
|
||||||
|
vm.$el.querySelector( 'button.clear' ).click()
|
||||||
|
expect(vm.mutableValue).toEqual(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user