34 lines
1.1 KiB
TypeScript
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("کنینا");
|
|
});
|
|
});
|