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);
});
