import {
  cleanup,
  render,
  screen,
} from "@testing-library/react";
import assert from "node:assert";
import {
  afterEach,
  describe,
  test,
} from "node:test";
import { Palette } from "./index";

describe("Palette", () => {
  afterEach(() => {
    cleanup();
  });

  test("renders default palette items", () => {
    render(<Palette items={[]} />);

    assert.notStrictEqual(screen.queryByText("white"), null);
    assert.notStrictEqual(screen.queryByText("black"), null);
  });

  test("renders custom children instead of generated items", () => {
    render(
      <Palette items={[ { color: "#f00", label: "red" } ]}>
        <span>Custom palette content</span>
      </Palette>
    );

    assert.notStrictEqual(screen.queryByText("Custom palette content"), null);
    assert.strictEqual(screen.queryByText("red"), null);
  });
});
