2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-19 09:50:33 +03:00

Complete labels spec

This commit is contained in:
Jeff
2018-08-12 13:42:07 -07:00
parent 0946165e9c
commit c03b634a24
+34 -40
View File
@@ -1,48 +1,42 @@
import { shallowMount } from "@vue/test-utils";
import VueSelect from "../../src/components/Select"; import VueSelect from "../../src/components/Select";
import { shallowMount } from "@vue/test-utils";
import { selectWithProps } from "../helpers";
describe("Labels", () => { describe("Labels", () => {
it("can generate labels using a custom label key", () => { it("can generate labels using a custom label key", () => {
const Select = shallowMount(VueSelect, { const Select = selectWithProps({
propsData: { options: [{ name: "Foo" }],
options: [{ name: "Foo" }], label: "name",
label: "name", value: { name: "Foo" }
value: { name: "Foo" }
}
}); });
expect(Select.find(".selected-tag").text()).toBe("Foo"); expect(Select.find(".selected-tag").text()).toBe("Foo");
}); });
//
// it("will console.warn when options contain objects without a valid label key", done => { it("will console.warn when options contain objects without a valid label key", () => {
// spyOn(console, "warn"); const spy = jest.spyOn(console, "warn");
// const vm = new Vue({ const Select = selectWithProps({
// template: '<div><v-select :options="[{}]"></v-select></div>' options: [{}]
// }).$mount(); });
// vm.$children[0].open = true;
// Vue.nextTick(() => { Select.vm.open = true;
// expect(console.warn).toHaveBeenCalledWith( expect(spy).toHaveBeenCalledWith(
// '[vue-select warn]: Label key "option.label" does not exist in options object {}.' + '[vue-select warn]: Label key "option.label" does not exist in options object {}.' +
// "\nhttp://sagalbot.github.io/vue-select/#ex-labels" "\nhttp://sagalbot.github.io/vue-select/#ex-labels"
// ); );
// done(); });
// });
// }); it("should display a placeholder if the value is empty", () => {
// const Select = shallowMount(VueSelect, {
// it("should display a placeholder if the value is empty", done => { propsData: {
// const vm = new Vue({ options: [{ label: "one" }]
// template: },
// '<div><v-select :options="options" placeholder="foo"></v-select></div>', attrs: {
// components: { vSelect }, placeholder: "foo"
// data: { }
// options: [{ label: "one" }] });
// }
// }).$mount(); expect(Select.vm.searchPlaceholder).toEqual("foo");
// Select.vm.mutableValue = { label: "one" };
// expect(vm.$children[0].searchPlaceholder).toEqual("foo"); expect(Select.vm.searchPlaceholder).not.toBeDefined();
// vm.$children[0].mutableValue = { label: "one" }; });
// Vue.nextTick(() => {
// expect(vm.$children[0].searchPlaceholder).not.toBeDefined();
// done();
// });
// });
}); });