2024-03-03 11:33:28 +00:00
|
|
|
import React from "react";
|
|
|
|
import { render, screen } from "@testing-library/react";
|
|
|
|
import { describe, expect, it } from "bun:test";
|
2024-04-27 16:17:56 +00:00
|
|
|
import ImageModerator, {
|
|
|
|
ImageModeratorProps,
|
|
|
|
} from "../../src/components/ImageModerator/ImageModerator";
|
2024-03-03 12:50:48 +00:00
|
|
|
|
|
|
|
const properties: ImageModeratorProps = {
|
2024-04-27 16:17:56 +00:00
|
|
|
acceptLabel: "Accept",
|
|
|
|
discardLabel: "Discard",
|
|
|
|
};
|
2024-03-03 11:33:28 +00:00
|
|
|
|
|
|
|
it("should render into the document", () => {
|
2024-04-27 16:17:56 +00:00
|
|
|
render(<ImageModerator {...properties} />);
|
2024-03-03 11:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should show a new image when accept button is clicked", () => {
|
2024-04-27 16:17:56 +00:00
|
|
|
const acceptButton = screen.getByText(properties.acceptLabel);
|
|
|
|
const imgElement = screen.getByRole("img");
|
|
|
|
const imgElementSrcBefore = imgElement.getAttribute("src");
|
|
|
|
acceptButton.click();
|
|
|
|
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
|
2024-03-03 11:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should show a new image when discard button is clicked", () => {
|
2024-04-27 16:17:56 +00:00
|
|
|
const discardButton = screen.getByText(properties.discardLabel);
|
|
|
|
const imgElement = screen.getByRole("img");
|
|
|
|
const imgElementSrcBefore = imgElement.getAttribute("src");
|
|
|
|
discardButton.click();
|
|
|
|
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
|
|
|
|
});
|