Files
MeshChatX/tests/frontend/DropDownMenu.test.js
Sudo-Ivan 39b8d5fef8
Some checks failed
Build Test / Build and Test (push) Failing after 6m1s
CI / lint (push) Failing after 1m27s
CI / build-frontend (push) Failing after 1m30s
CI / test-backend (push) Successful in 1m17s
CI / test-lang (push) Failing after 1m15s
Build and Publish Docker Image / build (push) Failing after 4m28s
Build and Publish Docker Image / build-dev (push) Failing after 5m38s
Security Scans / scan (push) Successful in 2m12s
Tests / test (push) Failing after 1m17s
Cleanup
2026-02-17 17:59:46 -06:00

47 lines
1.7 KiB
JavaScript

import { mount } from "@vue/test-utils";
import { describe, it, expect, vi } from "vitest";
import DropDownMenu from "../../meshchatx/src/frontend/components/DropDownMenu.vue";
function mountDropDown(slots = {}) {
return mount(DropDownMenu, {
slots: {
button: '<button type="button">Menu</button>',
items: '<div class="menu-item">Item 1</div>',
...slots,
},
global: {
directives: { "click-outside": { mounted: () => {}, unmounted: () => {} } },
},
});
}
describe("DropDownMenu UI", () => {
it("renders button slot", () => {
const wrapper = mountDropDown();
expect(wrapper.text()).toContain("Menu");
});
it("shows menu when button clicked", async () => {
const wrapper = mountDropDown();
expect(wrapper.vm.isShowingMenu).toBe(false);
await wrapper.find("button").trigger("click");
expect(wrapper.vm.isShowingMenu).toBe(true);
expect(wrapper.text()).toContain("Item 1");
});
it("hides menu when button clicked again", async () => {
const wrapper = mountDropDown();
await wrapper.find("button").trigger("click");
expect(wrapper.vm.isShowingMenu).toBe(true);
await wrapper.find("button").trigger("click");
expect(wrapper.vm.isShowingMenu).toBe(false);
});
it("renders items slot when open", async () => {
const wrapper = mountDropDown({ items: '<div class="custom-item">Custom</div>' });
await wrapper.find("button").trigger("click");
expect(wrapper.find(".custom-item").exists()).toBe(true);
expect(wrapper.text()).toContain("Custom");
});
});