38 lines
988 B
TypeScript
38 lines
988 B
TypeScript
|
import "@testing-library/jest-dom";
|
||
|
import { render, screen } from "@testing-library/react";
|
||
|
import AuthorChip from "@/components/author-chip";
|
||
|
import { describe, expect, test, it } from "@jest/globals";
|
||
|
import { allAuthors } from "@/.content-collections/generated";
|
||
|
|
||
|
describe("AuthorChip", () => {
|
||
|
test.each(allAuthors)("$displayName", (a) => {
|
||
|
render(<AuthorChip {...a!} />);
|
||
|
|
||
|
const person = screen.getByText(a.displayName);
|
||
|
expect(person)
|
||
|
//@ts-ignore
|
||
|
.toBeInTheDocument();
|
||
|
|
||
|
const avatarUrl = screen.getByRole("img", {
|
||
|
name: /Picture of/i,
|
||
|
});
|
||
|
expect(avatarUrl)
|
||
|
//@ts-ignore
|
||
|
.toBeInTheDocument();
|
||
|
|
||
|
if (a.bluesky !== undefined) {
|
||
|
const bluesky = screen.getByText(`@${a.bluesky!}`);
|
||
|
expect(bluesky)
|
||
|
//@ts-ignore
|
||
|
.toBeInTheDocument();
|
||
|
}
|
||
|
|
||
|
if (a.x !== undefined) {
|
||
|
const x = screen.getByText(`@${a.x!}`);
|
||
|
expect(x)
|
||
|
//@ts-ignore
|
||
|
.toBeInTheDocument();
|
||
|
}
|
||
|
});
|
||
|
});
|