Skip to content

Commit 156fcb1

Browse files
committed
- fix Vue 2 peer dependency
- fix typo in readme - add test coverage for focus/blur events
1 parent d262f6b commit 156fcb1

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#### Features
66
- AJAX Support
77
- Tagging
8-
- No JS Dependenciesp
98
- List Filtering/Searching
109
- Supports Vuex
1110
- Select Single/Multiple Options

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"url": "https://github.com/sagalbot/vue-select.git"
2626
},
2727
"peerDependencies": {
28-
"vue": "~1.0"
28+
"vue": "2.x"
2929
},
3030
"devDependencies": {
3131
"babel-core": "^6.0.0",

test/unit/specs/Select.spec.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ describe('Select.vue', () => {
131131
}).$mount()
132132
vm.$children[0].select('foo')
133133
expect(vm.$children[0].mutableValue.length).toEqual(1)
134+
}),
135+
136+
it('can deselect an option when multiple is false', () => {
137+
const vm = new Vue({
138+
template: `<div><v-select :value="'foo'"></v-select></div>`,
139+
}).$mount()
140+
vm.$children[0].deselect('foo')
141+
expect(vm.$children[0].mutableValue).toEqual(null)
134142
})
135143

136144
it('can determine if the value prop is empty', () => {
@@ -232,7 +240,14 @@ describe('Select.vue', () => {
232240
expect(vm.value).toEqual('bar')
233241
done()
234242
})
235-
})
243+
}),
244+
245+
it('can check if a string value is selected when the value is an object and multiple is true', () => {
246+
const vm = new Vue({
247+
template: `<div><v-select multiple :value="[{label: 'foo', value: 'bar'}]"></v-select></div>`,
248+
}).$mount()
249+
expect(vm.$children[0].isOptionSelected('foo')).toEqual(true)
250+
}),
236251

237252
describe('change Event', () => {
238253
it('will trigger the input event when the selection changes', (done) => {
@@ -351,6 +366,31 @@ describe('Select.vue', () => {
351366
expect(vm.$children[0].open).toEqual(true)
352367
})
353368

369+
it('will close the dropdown and emit the search:blur event from onSearchBlur', () => {
370+
const vm = new Vue({
371+
template: '<div><v-select></v-select></div>',
372+
}).$mount()
373+
374+
spyOn(vm.$children[0], '$emit')
375+
vm.$children[0].open = true
376+
vm.$children[0].onSearchBlur()
377+
378+
expect(vm.$children[0].open).toEqual(false)
379+
expect(vm.$children[0].$emit).toHaveBeenCalledWith('search:blur')
380+
})
381+
382+
it('will open the dropdown and emit the search:focus event from onSearchFocus', () => {
383+
const vm = new Vue({
384+
template: '<div><v-select></v-select></div>',
385+
}).$mount()
386+
387+
spyOn(vm.$children[0], '$emit')
388+
vm.$children[0].onSearchFocus()
389+
390+
expect(vm.$children[0].open).toEqual(true)
391+
expect(vm.$children[0].$emit).toHaveBeenCalledWith('search:focus')
392+
})
393+
354394
it('will close the dropdown on escape, if search is empty', (done) => {
355395
const vm = new Vue({
356396
template: '<div><v-select></v-select></div>',

0 commit comments

Comments
 (0)