diff --git a/src/App.tsx b/src/App.tsx index 9b590ff..b0cfcfc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,15 @@ import './App.css' -import ImageModerator from './components/ImageModerator/ImageModerator' +import ImageModerator, { ImageModeratorProps } from './components/ImageModerator/ImageModerator' + +const imageModeratorProps: ImageModeratorProps = { + acceptLabel: "Accept", + discardLabel: "Discard" +} function App() { return ( <> - + ) } diff --git a/src/components/ImageModerator/ImageModerator.tsx b/src/components/ImageModerator/ImageModerator.tsx index 21be10c..09b7c59 100644 --- a/src/components/ImageModerator/ImageModerator.tsx +++ b/src/components/ImageModerator/ImageModerator.tsx @@ -1,15 +1,49 @@ import Button from "../Button/Button"; +import { GelbooruAPIResponse } from "../../types/GelbooruAPIResponse"; +import { useEffect, useState } from "react"; export interface ImageModeratorProps { - apiEndpoint: string; - imageUrlProperty: string; + acceptLabel: string; + discardLabel: string; } -export default function ImageModerator({apiEndpoint, imageUrlProperty}: ImageModeratorProps) { - return
- -
} \ No newline at end of file diff --git a/test/unit/ImageModerator.test.tsx b/test/unit/ImageModerator.test.tsx index f281c74..fc65179 100644 --- a/test/unit/ImageModerator.test.tsx +++ b/test/unit/ImageModerator.test.tsx @@ -1,24 +1,29 @@ 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'; +import ImageModerator, { ImageModeratorProps } from '../../src/components/ImageModerator/ImageModerator'; + +const properties: ImageModeratorProps = { + acceptLabel: "Accept", + discardLabel: "Discard" +} it("should render into the document", () => { - render(); + render(); }); it("should show a new image when accept button is clicked", () => { - const acceptButton = screen.getByText("Accept"); + const acceptButton = screen.getByText(properties.acceptLabel); const imgElement = screen.getByRole("img"); const imgElementSrcBefore = imgElement.getAttribute("src"); - acceptButton.click() + 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 discardButton = screen.getByText(properties.discardLabel); const imgElement = screen.getByRole("img"); const imgElementSrcBefore = imgElement.getAttribute("src"); - discardButton.click() + discardButton.click(); expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore); -}); +}); \ No newline at end of file