52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
// The Lucia project.
|
|
// Copyright 2026-2026 DSP, inc. All rights reserved.
|
|
// Authors:
|
|
// imacat.yang@dsp.im (imacat), 2026/03/05
|
|
|
|
import { describe, it, expect, beforeEach } from "vitest";
|
|
import { mount } from "@vue/test-utils";
|
|
import { setActivePinia, createPinia } from "pinia";
|
|
import ModalHeader from "@/views/AccountManagement/ModalHeader.vue";
|
|
import { useModalStore } from "@/stores/modal";
|
|
|
|
describe("ModalHeader", () => {
|
|
let pinia;
|
|
|
|
beforeEach(() => {
|
|
pinia = createPinia();
|
|
setActivePinia(pinia);
|
|
});
|
|
|
|
const mountModalHeader = (headerText = "Test Header") => {
|
|
return mount(ModalHeader, {
|
|
props: { headerText },
|
|
global: { plugins: [pinia] },
|
|
});
|
|
};
|
|
|
|
it("renders header text from prop", () => {
|
|
const wrapper = mountModalHeader("Account Info");
|
|
expect(wrapper.find("h1").text()).toBe("Account Info");
|
|
});
|
|
|
|
it("renders close button (X icon)", () => {
|
|
const wrapper = mountModalHeader();
|
|
const img = wrapper.find('img[alt="X"]');
|
|
expect(img.exists()).toBe(true);
|
|
});
|
|
|
|
it("calls closeModal when X is clicked", async () => {
|
|
const wrapper = mountModalHeader();
|
|
const store = useModalStore();
|
|
store.isModalOpen = true;
|
|
store.whichModal = "SOME_MODAL";
|
|
|
|
const img = wrapper.find('img[alt="X"]');
|
|
await img.trigger("click");
|
|
|
|
// closeModal only sets isModalOpen to false; whichModal is not reset
|
|
expect(store.isModalOpen).toBe(false);
|
|
expect(store.whichModal).toBe("SOME_MODAL");
|
|
});
|
|
});
|