import { afterEach, describe, expect, it } from "vitest"; import { mount, type VueWrapper } from "@vue/test-utils"; import Footer from "~/layouts/default/Footer.vue"; describe("Footer.vue", () => { const RealDate = Date; const mockDate = (year: number) => { globalThis.Date = class extends RealDate { constructor() { super(); return new RealDate(`${year}-01-01`); } static now() { return new RealDate(`${year}-01-01`).getTime(); } }; }; afterEach(() => { globalThis.Date = RealDate; }); it("loads without crashing", () => { const wrapper: VueWrapper = mount(Footer, {}); expect(wrapper.exists()).toBe(true); expect(wrapper.find(".layout-footer").exists()).toBe(true); expect(wrapper.find(".layout-footer").classes()).toContain("font-bold"); }); it("displays only 'Glowing Fiesta 2025' when current year is 2025", () => { mockDate(2025); const wrapper = mount(Footer); expect(wrapper.text()).toBe("Glowing Fiesta 2025"); expect(wrapper.text()).not.toContain(" - "); }); it("displays 'Glowing Fiesta 2025 - 2034' when current year is 2034", () => { mockDate(2034); const wrapper = mount(Footer); expect(wrapper.text()).toBe("Glowing Fiesta 2025 - 2034"); }); it("has proper structure / content", () => { const wrapper = mount(Footer); const footer = wrapper.find("footer"); expect(footer.exists()).toBe(true); expect(footer.element.tagName).toBe("FOOTER"); expect(wrapper.findAll("div")).toHaveLength(1); }); });