diff --git a/test/unit/specs/Select.spec.js b/test/unit/specs/Select.spec.js
index e3ec599..5e15396 100644
--- a/test/unit/specs/Select.spec.js
+++ b/test/unit/specs/Select.spec.js
@@ -295,6 +295,15 @@ describe('Select.vue', () => {
expect(vm.$refs.select.filteredOptions).toEqual(['bar','baz'])
})
+ it('should not filter the array of strings if filterOptions is false', () => {
+ const vm = new Vue({
+ template: `
`,
+ data: {value: 'foo'}
+ }).$mount()
+ vm.$refs.select.search = 'ba'
+ expect(vm.$refs.select.filteredOptions).toEqual(['foo','bar','baz'])
+ })
+
it('should filter without case-sensitivity', () => {
const vm = new Vue({
template: `
`,
@@ -872,6 +881,21 @@ describe('Select.vue', () => {
expect(vm.$children[0].mutableOptions).toEqual(['one', 'two', 'three'])
})
+ it('should add a freshly created option/tag to the options list when pushTags is true and filterOptions is false', () => {
+ const vm = new Vue({
+ template: '
',
+ components: {vSelect},
+ data: {
+ value: ['one'],
+ options: ['one', 'two']
+ }
+ }).$mount()
+
+ searchSubmit(vm, 'three')
+ expect(vm.$children[0].mutableOptions).toEqual(['one', 'two', 'three'])
+ expect(vm.$children[0].filteredOptions).toEqual(['one', 'two', 'three'])
+ })
+
it('wont add a freshly created option/tag to the options list when pushTags is false', () => {
const vm = new Vue({
template: '
',
@@ -886,6 +910,21 @@ describe('Select.vue', () => {
expect(vm.$children[0].mutableOptions).toEqual(['one', 'two'])
})
+ it('wont add a freshly created option/tag to the options list when pushTags is false and filterOptions is false', () => {
+ const vm = new Vue({
+ template: '
',
+ components: {vSelect},
+ data: {
+ value: ['one'],
+ options: ['one', 'two']
+ }
+ }).$mount()
+
+ searchSubmit(vm, 'three')
+ expect(vm.$children[0].mutableOptions).toEqual(['one', 'two'])
+ expect(vm.$children[0].filteredOptions).toEqual(['one', 'two'])
+ })
+
it('should select an existing option if the search string matches a string from options', (done) => {
let two = 'two'
const vm = new Vue({
@@ -927,6 +966,28 @@ describe('Select.vue', () => {
})
})
+ it('should select an existing option if the search string matches an objects label from options when filter-options is false', (done) => {
+ let two = {label: 'two'}
+ const vm = new Vue({
+ template: '
',
+ data: {
+ options: [{label: 'one'}, two]
+ }
+ }).$mount()
+
+ vm.$children[0].search = 'two'
+
+ Vue.nextTick(() => {
+ searchSubmit(vm)
+ // This needs to be wrapped in nextTick() twice so that filteredOptions can
+ // calculate after setting the search text, and move the typeAheadPointer index to 0.
+ Vue.nextTick(() => {
+ expect(vm.$children[0].mutableValue.label).toBe(two.label)
+ done()
+ })
+ })
+ })
+
it('should not reset the selected value when the options property changes', (done) => {
const vm = new Vue({
template: '
',
@@ -943,6 +1004,22 @@ describe('Select.vue', () => {
})
})
+ it('should not reset the selected value when the options property changes when filterOptions is false', (done) => {
+ const vm = new Vue({
+ template: '
',
+ components: {vSelect},
+ data: {
+ value: [{label: 'one'}],
+ options: [{label: 'one'}]
+ }
+ }).$mount()
+ vm.$children[0].mutableOptions = [{label: 'two'}]
+ Vue.nextTick(() => {
+ expect(vm.$children[0].mutableValue).toEqual([{label: 'one'}])
+ done()
+ })
+ })
+
it('should not allow duplicate tags when using string options', (done) => {
const vm = new Vue({
template: `
`,