glowing-fiesta/tests/layouts/default/Footer.test.ts
Liviu Burcusel d1967f718e
Added default layout to project
* Added default layout for the site

* App is in light mode by default.

* App is in light mode by default.
2025-11-12 12:50:56 +01:00

55 lines
1.5 KiB
TypeScript

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);
});
});