Files
canina/frontend/application/app/blog/blog-page.test.tsx
T
devops 159e4a4cbf
Deploy Canina / deploy (push) Successful in 2m47s
fix(blog): separate Canina author and editorial team
2026-10-20 07:52:07 +00:00

34 lines
1.1 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
import Blog from "./page";
const blogPageSpy = vi.fn();
vi.mock("../../components/BlogPage", () => ({
default: (props: unknown) => {
blogPageSpy(props);
return null;
},
}));
vi.mock("../../lib/seo", () => ({ getPageMetadata: vi.fn() }));
vi.mock("../../lib/media", () => ({ getMediaUrl: (value: string) => value }));
describe("blog page author identity", () => {
beforeEach(() => {
blogPageSpy.mockClear();
vi.stubGlobal("fetch", vi.fn()
.mockResolvedValueOnce({
ok: true,
json: async () => ({ data: [{ id: "b1", slug: "post", title: "Post", content: "Body" }] }),
})
.mockResolvedValueOnce({ ok: true, json: async () => ({ data: [] }) }));
});
it("uses the scientific content team for an authorless blog card", async () => {
const element = await Blog({ searchParams: Promise.resolve({}) });
element.type(element.props);
const props = blogPageSpy.mock.calls[0][0] as { blogs: Array<{ author: string }> };
expect(props.blogs[0].author).toBe("کنینا");
});
});