diff --git a/tests/unit/Layout.spec.js b/tests/unit/Layout.spec.js index 63e1ee2..9fb84fb 100644 --- a/tests/unit/Layout.spec.js +++ b/tests/unit/Layout.spec.js @@ -13,58 +13,31 @@ describe("Single value options", () => { expect(Select.vm.search).toEqual(""); }); - // it('should apply the "hidden" class to the search input when a value is present', () => { - // const vm = new Vue({ - // template: - // '
', - // data: { - // value: "one", - // options: ["one", "two", "three"] - // } - // }).$mount(); - // - // expect(vm.$children[0].inputClasses.hidden).toEqual(true); - // }); - // - // it('should not apply the "hidden" class to the search input when a value is present, and the dropdown is open', done => { - // const vm = new Vue({ - // template: - // '
', - // data: { - // value: "one", - // options: ["one", "two", "three"], - // open: true - // } - // }).$mount(); - // vm.$children[0].toggleDropdown({ target: vm.$children[0].$refs.search }); - // Vue.nextTick(() => { - // Vue.nextTick(() => { - // expect(vm.$children[0].open).toEqual(true); - // expect(vm.$children[0].inputClasses.hidden).toEqual(false); - // done(); - // }); - // }); - // }); - // - // it("should not reset the search input on focus lost when clearSearchOnSelect is false", done => { - // const vm = new Vue({ - // template: - // '
', - // data: { - // value: "one", - // options: ["one", "two", "three"] - // } - // }).$mount(); - // expect(vm.$refs.select.clearSearchOnSelect).toEqual(false); - // - // vm.$children[0].open = true; - // vm.$refs.select.search = "t"; - // expect(vm.$refs.select.search).toEqual("t"); - // - // vm.$children[0].onSearchBlur(); - // Vue.nextTick(() => { - // expect(vm.$refs.select.search).toEqual("t"); - // done(); - // }); - // }); + it('should apply the "hidden" class to the search input when a value is present', () => { + const Select = shallowMount(VueSelect, { propsData: { value: "foo" } }); + expect(Select.vm.inputClasses.hidden).toEqual(true); + }); + + it('should not apply the "hidden" class to the search input when a value is present, and the dropdown is open', () => { + const Select = shallowMount(VueSelect, { propsData: { value: "foo" } }); + Select.vm.toggleDropdown({ target: Select.vm.$refs.search }); + + expect(Select.vm.open).toEqual(true); + expect(Select.vm.inputClasses.hidden).toEqual(false); + }); + + it("should not reset the search input on focus lost when clearSearchOnSelect is false", () => { + const Select = shallowMount(VueSelect, { + propsData: { value: "foo", clearSearchOnSelect: false } + }); + + expect(Select.vm.clearSearchOnSelect).toEqual(false); + + Select.vm.open = true; + Select.vm.search = "t"; + expect(Select.vm.search).toEqual("t"); + + Select.vm.onSearchBlur(); + expect(Select.vm.search).toEqual("t"); + }); });