Skip to content

Commit

Permalink
test: add image details base unit test
Browse files Browse the repository at this point in the history
Refs: IS-10
  • Loading branch information
ythepaut committed Aug 17, 2024
1 parent 444b2de commit efbb29d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
35 changes: 35 additions & 0 deletions tests/components/ImageDetailModal.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { render, screen } from "@testing-library/react";
import React from "react";
import ImageDetailModal from "../../src/components/ImageDetailModal";
import { Image } from "../../src/model/image";
import { expect } from "@jest/globals";

//mock bigger-picture
jest.mock("bigger-picture", () => {
return () => {
return {
open: () => {},
close: () => {}
}
};
});

describe("ImageDetailModal", () => {
it("should render", () => {
// Given
const image: Image = {
src: "/test.png",
alt: "alt",
width: 100,
height: 100,
id: "1"
};

// When
render(<ImageDetailModal image={image} onClose={() => {}} />);

// Then
const imageTitleLabel = screen.getByText(image.alt);
expect(imageTitleLabel).toBeInTheDocument();
});
});
5 changes: 3 additions & 2 deletions tests/components/gallery/ImageTile.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ describe("ImageTile", () => {
src: "/test.png",
alt: "alt",
width: 100,
height: 100
height: 100,
id: "1"
};

// When
render(<ImageTile image={image} />);
render(<ImageTile image={image} onClick={() => {}} />);

// Then
const imageElement = screen.getByRole("img");
Expand Down

0 comments on commit efbb29d

Please sign in to comment.