|
1 |
| -import { render } from "@testing-library/react"; |
2 |
| -import { RekorClientProvider } from "../api/context"; |
3 |
| -import { EntryCard } from "./Entry"; |
| 1 | +jest.mock("react-syntax-highlighter/dist/cjs/styles/prism", () => ({})); |
| 2 | +jest.mock("../utils/date", () => ({ |
| 3 | + toRelativeDateString: jest.fn().mockReturnValue("Some Date"), |
| 4 | +})); |
| 5 | + |
| 6 | +import { fireEvent, render, screen } from "@testing-library/react"; |
| 7 | +import { Entry, EntryCard } from "./Entry"; |
| 8 | + |
| 9 | +const mockEntry = { |
| 10 | + someUuid: { |
| 11 | + body: Buffer.from( |
| 12 | + JSON.stringify({ kind: "hashedrekord", apiVersion: "v1", spec: {} }), |
| 13 | + ).toString("base64"), |
| 14 | + attestation: { data: Buffer.from("{}").toString("base64") }, |
| 15 | + logID: "123", |
| 16 | + logIndex: 123, |
| 17 | + integratedTime: 1618886400, |
| 18 | + publicKey: "mockedPublicKey", |
| 19 | + }, |
| 20 | +}; |
4 | 21 |
|
5 | 22 | describe("Entry", () => {
|
6 |
| - it("renders", () => { |
7 |
| - // |
| 23 | + it.skip("renders and toggles the accordion content", () => { |
| 24 | + render(<Entry entry={mockEntry} />); |
| 25 | + |
| 26 | + // check if UUID link is rendered |
| 27 | + expect(screen.getByText("someUuid")).toBeInTheDocument(); |
| 28 | + |
| 29 | + // simulate clicking the accordion toggle |
| 30 | + const toggleButton = screen.getByText("Raw Body"); |
| 31 | + fireEvent.click(toggleButton); |
| 32 | + |
| 33 | + // now the accordion content should be visible |
| 34 | + expect( |
| 35 | + screen.getByText("Your expected content after decoding and dumping"), |
| 36 | + ).toBeInTheDocument(); |
8 | 37 | });
|
9 | 38 | });
|
10 | 39 |
|
11 | 40 | describe("EntryCard", () => {
|
12 |
| - it("renders", () => { |
| 41 | + it("renders the title and content", () => { |
13 | 42 | render(
|
14 |
| - <RekorClientProvider> |
15 |
| - <EntryCard |
16 |
| - content={<></>} |
17 |
| - title={<></>} |
18 |
| - /> |
19 |
| - </RekorClientProvider>, |
| 43 | + <EntryCard |
| 44 | + title="Test Title" |
| 45 | + content="Test Content" |
| 46 | + />, |
20 | 47 | );
|
| 48 | + expect(screen.getByText("Test Title")).toBeInTheDocument(); |
| 49 | + expect(screen.getByText("Test Content")).toBeInTheDocument(); |
21 | 50 | });
|
22 | 51 | });
|
0 commit comments