mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
add1a5282b
* chore: yarn upgrade * upgrade vue test utils * fix selectable suite * fix slot suite * fix ajax suite * fix reactive options suite * fix typeahead suite * fix reduce tests * fix tagging suite * fix deselecting * fix deselecting * fix deselecting
45 lines
1.3 KiB
JavaScript
Executable File
45 lines
1.3 KiB
JavaScript
Executable File
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(".vs__selected").text()).toBe("Foo");
|
|
});
|
|
|
|
it("will console.warn when options contain objects without a valid label key", async () => {
|
|
const spy = jest.spyOn(console, "warn").mockImplementation(() => {});
|
|
const Select = selectWithProps({
|
|
options: [{}]
|
|
});
|
|
|
|
Select.vm.open = true;
|
|
await Select.vm.$nextTick();
|
|
|
|
expect(spy).toHaveBeenCalledWith(
|
|
'[vue-select warn]: Label key "option.label" does not exist in options object {}.' +
|
|
"\nhttps://vue-select.org/api/props.html#getoptionlabel"
|
|
);
|
|
});
|
|
|
|
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.$data._value = "one";
|
|
expect(Select.vm.searchPlaceholder).not.toBeDefined();
|
|
});
|
|
});
|