2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-22 10:30:34 +03:00

add Jest suite from vue-cli-3 branch

This commit is contained in:
Jeff
2019-02-10 14:38:30 -08:00
parent 4ed24ab2e3
commit e03c642615
13 changed files with 1330 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
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 = 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", () => {
const spy = jest.spyOn(console, "warn").mockImplementation(() => {});
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: ["one"]
},
attrs: {
placeholder: "foo"
}
});
expect(Select.vm.searchPlaceholder).toEqual("foo");
Select.vm.mutableValue = "one";
expect(Select.vm.searchPlaceholder).not.toBeDefined();
});
});