mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-16 09:10:33 +03:00
enforce value param to be of type array
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
/* global describe, it, expect */
|
||||
|
||||
import Vue from 'vue'
|
||||
import Hello from '../../src/components/Hello.vue'
|
||||
|
||||
describe('Hello.vue', () => {
|
||||
it('should render correct contents', () => {
|
||||
const vm = new Vue({
|
||||
template: '<div><hello></hello></div>',
|
||||
components: { Hello }
|
||||
}).$mount()
|
||||
expect(vm.$el.querySelector('.hello h1').textContent).toBe('Hello World!')
|
||||
})
|
||||
})
|
||||
|
||||
// also see example testing a component with mocks at
|
||||
// https://github.com/vuejs/vueify-example/blob/master/test/unit/a.spec.js#L22-L43
|
||||
@@ -0,0 +1,40 @@
|
||||
/* global describe, it, expect */
|
||||
|
||||
import Vue from 'vue'
|
||||
import vSelect from '../../src/components/Select.vue'
|
||||
|
||||
describe('Select.vue', () => {
|
||||
it('can accept an array with pre-selected values', () => {
|
||||
const vm = new Vue({
|
||||
template: '<div><v-select :value.sync="value"></v-select></div>',
|
||||
components: { vSelect },
|
||||
data: {
|
||||
value: ['one'],
|
||||
options: ['one','two','three']
|
||||
}
|
||||
}).$mount()
|
||||
|
||||
expect(vm.$children[0].value).toEqual(['one'])
|
||||
})
|
||||
|
||||
/**
|
||||
* TODO: Right now this only works for arrays of strings.. But the same method
|
||||
* should apply to arrays of objects.
|
||||
*/
|
||||
it('can accept an array of objects and pre-selected values', () => {
|
||||
const vm = new Vue({
|
||||
template: '<div><v-select :value.sync="value"></v-select></div>',
|
||||
components: { vSelect },
|
||||
data: {
|
||||
value: [{label: 'This is Foo', value: 'foo'}],
|
||||
options: [{label: 'This is Foo', value: 'foo'}, {label: 'This is Bar', value: 'bar'}]
|
||||
}
|
||||
}).$mount()
|
||||
|
||||
expect(vm.$children[0].$get('value')).toEqual({label: 'This is Foo', value: 'foo'})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// also see example testing a component with mocks at
|
||||
// https://github.com/vuejs/vueify-example/blob/master/test/unit/a.spec.js#L22-L43
|
||||
Reference in New Issue
Block a user