mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-07 07:12:23 +03:00
fix #54 and add regression test, use 2 space indents
This commit is contained in:
@@ -7,7 +7,8 @@ Rather than bringing in jQuery just to use Select2 or Chosen, this Vue.js compon
|
||||
|
||||
#### Features
|
||||
|
||||
- **Tagging Support (+v.1.1.0)**
|
||||
- **AJAX Support +v1.2.0**
|
||||
- Tagging Support **+v.1.1.0**
|
||||
- No JS Dependencies
|
||||
- List Filtering/Searching
|
||||
- Supports Vuex
|
||||
@@ -17,9 +18,9 @@ Rather than bringing in jQuery just to use Select2 or Chosen, this Vue.js compon
|
||||
|
||||
#### Upcoming/In Progress
|
||||
|
||||
- ~~Tagging (adding options not present in list, see `taggable` branch)~~ **added in v.1.1.0**
|
||||
- ~~Tagging (adding options not present in list, see `taggable` branch)~~ **+v.1.1.0**
|
||||
- ~~Asyncronous Option Loading~~ **+v.1.2.0**
|
||||
- Rich Option Templating
|
||||
- Asyncronous Option Loading
|
||||
|
||||
## Live Examples & Docs
|
||||
[http://sagalbot.github.io/vue-select/](http://sagalbot.github.io/vue-select/)
|
||||
|
||||
+539
-531
File diff suppressed because it is too large
Load Diff
@@ -190,31 +190,56 @@ describe('Select.vue', () => {
|
||||
expect(vm.$children[0].isOptionSelected('one')).toEqual(true)
|
||||
})
|
||||
|
||||
it('can run a callback when the selection changes', (done) => {
|
||||
const vm = new Vue({
|
||||
template: '<div><v-select :on-change="foo" value="bar" :options="options"></v-select></div>',
|
||||
components: {vSelect},
|
||||
data: {
|
||||
val: null,
|
||||
options: ['foo', 'bar', 'baz']
|
||||
},
|
||||
methods: {
|
||||
foo(value) {
|
||||
this.val = value
|
||||
describe('onChange Callback', () => {
|
||||
it('can run a callback when the selection changes', (done) => {
|
||||
const vm = new Vue({
|
||||
template: `<div><v-select :value="['foo']" :options="['foo','bar','baz']" :on-change="cb"></v-select></div>`,
|
||||
components: {vSelect},
|
||||
methods: {
|
||||
cb(val) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).$mount()
|
||||
}).$mount()
|
||||
|
||||
vm.$children[0].select('foo')
|
||||
Vue.nextTick(function () {
|
||||
expect(vm.$get('val')).toEqual('foo')
|
||||
spyOn(vm.$children[0], 'onChange')
|
||||
|
||||
vm.$children[0].$set('value', 'baz')
|
||||
Vue.nextTick(function () {
|
||||
expect(vm.$get('val')).toEqual('baz')
|
||||
done()
|
||||
vm.$children[0].select('bar')
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(vm.$children[0].onChange).toHaveBeenCalledWith('bar')
|
||||
vm.$children[0].select('baz')
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(vm.$children[0].onChange).toHaveBeenCalledWith('baz')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should run onChange when multiple is true and the value changes', (done) => {
|
||||
const vm = new Vue({
|
||||
template: `<div><v-select v-ref:select :value="['foo']" :options="['foo','bar','baz']" multiple :on-change="cb"></v-select></div>`,
|
||||
methods: {
|
||||
cb(val) {
|
||||
}
|
||||
}
|
||||
}).$mount()
|
||||
|
||||
spyOn(vm.$children[0], 'onChange')
|
||||
|
||||
vm.$children[0].select('bar')
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(vm.$children[0].onChange).toHaveBeenCalledWith(['foo','bar'])
|
||||
vm.$children[0].select('baz')
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(vm.$children[0].onChange).toHaveBeenCalledWith(['foo','bar','baz'])
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user