mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
Merge pull request #14 from sagalbot/pr/12
also run assertions on labels, fix ‘resets the selected values when the
This commit is contained in:
@@ -43,6 +43,7 @@ describe('Select.vue', () => {
|
||||
}).$mount()
|
||||
|
||||
expect( vm.$children[0].$get('value').value ).toEqual( 'foo' )
|
||||
expect( vm.$children[0].$get('value').label ).toEqual( 'This is Foo' )
|
||||
})
|
||||
|
||||
it('can accept an array of objects and pre-selected values (multiple)', () => {
|
||||
@@ -56,9 +57,13 @@ describe('Select.vue', () => {
|
||||
}).$mount()
|
||||
|
||||
var values = vm.$children[0].$get('value')
|
||||
var labels = []
|
||||
|
||||
labels = values.map( value => value.label )
|
||||
values = values.map( value => value.value )
|
||||
|
||||
expect( values ).toEqual( ['foo', 'bar'] )
|
||||
expect( labels ).toEqual( ['This is Foo', 'This is Bar'] )
|
||||
})
|
||||
|
||||
it('can determine if the value prop is empty', () => {
|
||||
@@ -84,9 +89,9 @@ describe('Select.vue', () => {
|
||||
expect(select.isValueEmpty).toEqual(true)
|
||||
})
|
||||
|
||||
it('resets the selected values when the options property changes', () => {
|
||||
it('resets the selected values when the options property changes', (done) => {
|
||||
const vm = new Vue({
|
||||
template: '<div><v-select :value.sync="value"></v-select></div>',
|
||||
template: '<div><v-select :value.sync="value" :multiple="true"></v-select></div>',
|
||||
components: { vSelect },
|
||||
data: {
|
||||
value: ['one'],
|
||||
@@ -95,7 +100,11 @@ describe('Select.vue', () => {
|
||||
}).$mount()
|
||||
|
||||
vm.$children[0].options = ['four','five','six']
|
||||
expect(vm.$children[0].$get('value')).toEqual([])
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(vm.$children[0].$get('value')).toEqual([])
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('can retain values present in a new array of options', () => {
|
||||
|
||||
Reference in New Issue
Block a user