import React from "react";
import { render } from "@testing-library/react";
import "@testing-library/jest-dom";
import Barcode from "../QRCode";

describe("QRCode Component Tests", () => {
  it("should render without crashing", () => {
    render(<Barcode value="123456" />);
    const svgElement = document.querySelector("svg");
    expect(svgElement).toBeInTheDocument();
  });

  it("should correctly render with given props", () => {
    const testProps = {
      dataTestId: "test-id",
      background: "white",
      color: "black",
      height: 100,
      width: 200,
      value: "123456",
    };

    render(<Barcode {...testProps} />);
    const svgElement = document.querySelector("svg");

    expect(svgElement).toBeInTheDocument();
  });

  it("should match snapshot", () => {
    const { asFragment } = render(<Barcode value="123456" />);
    expect(asFragment()).toMatchSnapshot();
  });
});
