Skip to content

Commit

Permalink
Migrated object-store/object/external-resource-view.test.tsx to RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmacalintal committed Dec 23, 2024
1 parent 260aff4 commit 56c7ffb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { mountWithAppContext2 } from "../../../../test-util/mock-app-context";
import MetadataRevisionListPage from "../../../../pages/object-store/metadata/revisions";
import { DefaultRow } from "../../../../../common-ui/lib";
import { fireEvent, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import userEvent from "@testing-library/user-event";

const TEST_SNAPSHOTS = [
{
Expand Down Expand Up @@ -56,8 +54,6 @@ describe("MetadataRevisionListPage", () => {
// Await metadata query:
await new Promise(setImmediate);

screen.logTestingPlaygroundURL();

// Renders the title:
expect(
wrapper.getByRole("heading", { name: /revisions for my\-image\.png/i })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PersistedResource } from "kitsu";
import ExternalResourceMetadataViewPage from "../../../../dina-ui/pages/object-store/object/external-resource-view";
import { mountWithAppContext } from "../../../../dina-ui/test-util/mock-app-context";
import { mountWithAppContext2 } from "../../../../dina-ui/test-util/mock-app-context";
import { Metadata } from "../../../../dina-ui/types/objectstore-api/resources/Metadata";
import "@testing-library/jest-dom";

const TEST_METADATA: PersistedResource<Metadata> = {
acSubtype: "TEST_SUBTYPE",
Expand Down Expand Up @@ -55,20 +56,23 @@ jest.mock("next/router", () => ({

describe("Stored Object external resource view page", () => {
it("Renders the page.", async () => {
const wrapper = mountWithAppContext(<ExternalResourceMetadataViewPage />, {
const wrapper = mountWithAppContext2(<ExternalResourceMetadataViewPage />, {
apiContext
});

await new Promise(setImmediate);
wrapper.update();

// Shows the caption
expect(wrapper.contains("test caption")).toBeTruthy();
expect(
wrapper.getByRole("cell", { name: /test caption/i })
).toBeInTheDocument();

// Shows the resource URL
expect(wrapper.contains("http://agr.gc.ca")).toEqual(true);
expect(
wrapper.getByRole("cell", { name: /http:\/\/agr\.gc\.ca/i })
).toBeInTheDocument();

// Shows the media format:
expect(wrapper.contains("jpeg")).toEqual(true);
expect(wrapper.getByRole("cell", { name: /jpeg/i })).toBeInTheDocument();
});
});

0 comments on commit 56c7ffb

Please sign in to comment.