Skip to content

Commit baa1b4e

Browse files
committed
feat(tests): add a bit more tests
1 parent 4575963 commit baa1b4e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Select.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ describe("input + menu interactions behavior", () => {
6666
expect(wrapper.findAll("div[role='option']").length).toBe(options.length);
6767
});
6868

69+
it("should open the menu when clicking on the dropdown button", async () => {
70+
const wrapper = mount(VueSelect, { props: { modelValue: null, options } });
71+
72+
await wrapper.get(".dropdown-icon").trigger("click");
73+
74+
expect(wrapper.findAll("div[role='option']").length).toBe(options.length);
75+
});
76+
6977
it("should close the menu after focusing and pressing tab", async () => {
7078
const wrapper = mount(VueSelect, { props: { modelValue: null, options } });
7179

@@ -327,6 +335,17 @@ describe("clear button", () => {
327335
expect(wrapper.emitted("update:modelValue")).toStrictEqual([[options[0].value], [undefined]]);
328336
expect(wrapper.find(".clear-button").exists()).toBe(false);
329337
});
338+
339+
it("should clear all selected options when clicking on the clear button with isMulti prop", async () => {
340+
const wrapper = mount(VueSelect, { props: { modelValue: [], isMulti: true, options, isClearable: true } });
341+
342+
await openMenu(wrapper);
343+
await wrapper.get("div[role='option']").trigger("click");
344+
await wrapper.get(".clear-button").trigger("click");
345+
346+
expect(wrapper.props("modelValue")).toStrictEqual([options[0].value]);
347+
expect(wrapper.find(".clear-button").exists()).toBe(false);
348+
});
330349
});
331350

332351
describe("search emit", () => {

0 commit comments

Comments
 (0)