Added test for renewing image when any button is clicked
This commit is contained in:
parent
5aa75bc12d
commit
cb266e1704
|
@ -1,8 +0,0 @@
|
|||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, it } from "bun:test";
|
||||
import ImageModerator from '../src/components/ImageModerator/ImageModerator';
|
||||
|
||||
it("should render without crashing", () => {
|
||||
render(<ImageModerator apiEndpoint='"https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&json=1"' imageUrlProperty='post[0]' />);
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
import React from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import ImageModerator from '../../src/components/ImageModerator/ImageModerator';
|
||||
|
||||
it("should render into the document", () => {
|
||||
render(<ImageModerator apiEndpoint='"https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&json=1"' imageUrlProperty='post[0]' />);
|
||||
});
|
||||
|
||||
it("should show a new image when accept button is clicked", () => {
|
||||
const acceptButton = screen.getByText("Accept");
|
||||
const imgElement = screen.getByRole("img");
|
||||
const imgElementSrcBefore = imgElement.getAttribute("src");
|
||||
acceptButton.click()
|
||||
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
|
||||
});
|
||||
|
||||
it("should show a new image when discard button is clicked", () => {
|
||||
const discardButton = screen.getByText("Discard");
|
||||
const imgElement = screen.getByRole("img");
|
||||
const imgElementSrcBefore = imgElement.getAttribute("src");
|
||||
discardButton.click()
|
||||
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
|
||||
});
|
Loading…
Reference in New Issue