diff --git a/tests/unit/Labels.spec.js b/tests/unit/Labels.spec.js
index 60440f8..cc9a28d 100644
--- a/tests/unit/Labels.spec.js
+++ b/tests/unit/Labels.spec.js
@@ -1,48 +1,42 @@
-import { shallowMount } from "@vue/test-utils";
import VueSelect from "../../src/components/Select";
+import { shallowMount } from "@vue/test-utils";
+import { selectWithProps } from "../helpers";
describe("Labels", () => {
it("can generate labels using a custom label key", () => {
- const Select = shallowMount(VueSelect, {
- propsData: {
- options: [{ name: "Foo" }],
- label: "name",
- value: { name: "Foo" }
- }
+ const Select = selectWithProps({
+ options: [{ name: "Foo" }],
+ label: "name",
+ value: { name: "Foo" }
});
expect(Select.find(".selected-tag").text()).toBe("Foo");
});
- //
- // it("will console.warn when options contain objects without a valid label key", done => {
- // spyOn(console, "warn");
- // const vm = new Vue({
- // template: '
'
- // }).$mount();
- // vm.$children[0].open = true;
- // Vue.nextTick(() => {
- // expect(console.warn).toHaveBeenCalledWith(
- // '[vue-select warn]: Label key "option.label" does not exist in options object {}.' +
- // "\nhttp://sagalbot.github.io/vue-select/#ex-labels"
- // );
- // done();
- // });
- // });
- //
- // it("should display a placeholder if the value is empty", done => {
- // const vm = new Vue({
- // template:
- // '
',
- // components: { vSelect },
- // data: {
- // options: [{ label: "one" }]
- // }
- // }).$mount();
- //
- // expect(vm.$children[0].searchPlaceholder).toEqual("foo");
- // vm.$children[0].mutableValue = { label: "one" };
- // Vue.nextTick(() => {
- // expect(vm.$children[0].searchPlaceholder).not.toBeDefined();
- // done();
- // });
- // });
+
+ it("will console.warn when options contain objects without a valid label key", () => {
+ const spy = jest.spyOn(console, "warn");
+ const Select = selectWithProps({
+ options: [{}]
+ });
+
+ Select.vm.open = true;
+ expect(spy).toHaveBeenCalledWith(
+ '[vue-select warn]: Label key "option.label" does not exist in options object {}.' +
+ "\nhttp://sagalbot.github.io/vue-select/#ex-labels"
+ );
+ });
+
+ it("should display a placeholder if the value is empty", () => {
+ const Select = shallowMount(VueSelect, {
+ propsData: {
+ options: [{ label: "one" }]
+ },
+ attrs: {
+ placeholder: "foo"
+ }
+ });
+
+ expect(Select.vm.searchPlaceholder).toEqual("foo");
+ Select.vm.mutableValue = { label: "one" };
+ expect(Select.vm.searchPlaceholder).not.toBeDefined();
+ });
});