Skip to content

Commit 1f8b301

Browse files
committed
Added code coverage for the additional logic.
1 parent 4bd8cc8 commit 1f8b301

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/unit/specs/Select.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,4 +1104,47 @@ describe('Select.vue', () => {
11041104
})
11051105
})
11061106
})
1107+
1108+
describe('Single value options', () => {
1109+
it('should reset the search input on focus lost', (done) => {
1110+
const vm = new Vue({
1111+
template: '<div><v-select ref="select" :options="options" :value="value"></v-select></div>',
1112+
data: {
1113+
value: 'one',
1114+
options: ['one', 'two', 'three']
1115+
}
1116+
}).$mount()
1117+
1118+
vm.$children[0].open = true
1119+
vm.$refs.select.search = "t"
1120+
expect(vm.$refs.select.search).toEqual('t')
1121+
1122+
vm.$children[0].onSearchBlur()
1123+
Vue.nextTick(() => {
1124+
expect(vm.$refs.select.search).toEqual('')
1125+
done()
1126+
})
1127+
})
1128+
1129+
it ('should not reset the search input on focus lost when clearSearchOnSelect is false', (done) => {
1130+
const vm = new Vue({
1131+
template: '<div><v-select ref="select" :options="options" :value="value" :clear-search-on-select="false"></v-select></div>',
1132+
data: {
1133+
value: 'one',
1134+
options: ['one', 'two', 'three']
1135+
}
1136+
}).$mount()
1137+
expect(vm.$refs.select.clearSearchOnSelect).toEqual(false)
1138+
1139+
vm.$children[0].open = true
1140+
vm.$refs.select.search = "t"
1141+
expect(vm.$refs.select.search).toEqual('t')
1142+
1143+
vm.$children[0].onSearchBlur()
1144+
Vue.nextTick(() => {
1145+
expect(vm.$refs.select.search).toEqual('t')
1146+
done()
1147+
})
1148+
})
1149+
})
11071150
})

0 commit comments

Comments
 (0)