57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
// @vitest-environment jsdom
|
|
|
|
import { mount } from "@vue/test-utils";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("vue-i18n", () => ({
|
|
useI18n: () => ({
|
|
t: (key, params = {}) =>
|
|
key === "invoice_period.flags.badge.summary" ? `${params.red} red and ${params.yellow} yellow` : key,
|
|
locale: { value: "en" },
|
|
}),
|
|
}));
|
|
|
|
vi.mock("sweetalert2", () => ({
|
|
default: { fire: vi.fn(async () => ({ isConfirmed: false })) },
|
|
}));
|
|
|
|
vi.mock("@/components/session/token/SessionUser.vue", () => ({
|
|
SessionUser: {
|
|
request: vi.fn(),
|
|
functions: { redirectTo: { department: vi.fn(), superUser: vi.fn() } },
|
|
},
|
|
}));
|
|
|
|
vi.mock("@/components/displays/PopperDefault.vue", () => ({
|
|
popperBox: vi.fn(),
|
|
removePopperIfOpen: vi.fn(),
|
|
showPopper: vi.fn(),
|
|
}));
|
|
|
|
import InvoicingPeriodFlagBadge from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/components/InvoicingPeriodFlagBadge.vue";
|
|
|
|
describe("InvoicingPeriodFlagBadge with Buefy", () => {
|
|
it("opens the dropdown when the badge trigger button is clicked", async () => {
|
|
globalThis.ResizeObserver = class ResizeObserver {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
};
|
|
const wrapper = mount(InvoicingPeriodFlagBadge, {
|
|
attachTo: document.body,
|
|
props: {
|
|
flags: [{ id: 1, source: "manual", status: "active", reason: "Review" }],
|
|
},
|
|
});
|
|
|
|
expect(wrapper.get(".dropdown").classes()).not.toContain("is-active");
|
|
await wrapper.get(".invoice-period-flag-badge__trigger").trigger("click");
|
|
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
|
await wrapper.vm.$nextTick();
|
|
|
|
expect(wrapper.get(".dropdown").classes()).toContain("is-active");
|
|
expect(document.body.textContent).toContain("Review");
|
|
wrapper.unmount();
|
|
});
|
|
});
|