import { describe, it, expect } from "vitest";
import { jsdomVitestConfig } from "./vitest.base.jsdom";

// jsdomVitestConfig is built with mergeConfig(nodeVitestConfig, ...).
// mergeConfig concatenates arrays rather than replacing them, so:
//   - setupFiles inherits the node setup file (currently a no-op) AND adds the jsdom one
//   - include inherits the node patterns AND adds the tsx-aware patterns (the file globs deduplicate at resolution)
// We assert the EXACT merged arrays so any future change to setup/node.ts or to include
// behavior is consciously visible in this test.

describe("jsdomVitestConfig", () => {
  it("uses jsdom environment", () => {
    expect(jsdomVitestConfig.test?.environment).toBe("jsdom");
  });
  it("loads both the node setup (no-op) and jsdom setup files", () => {
    expect(jsdomVitestConfig.test?.setupFiles).toEqual([
      "@repo/core-testing/setup/node",
      "@repo/core-testing/setup/jsdom",
    ]);
  });
  it("merges include globs from node base with the tsx-aware patterns", () => {
    expect(jsdomVitestConfig.test?.include).toEqual([
      "src/**/*.test.ts",
      "tests/**/*.test.ts",
      "src/**/*.test.{ts,tsx}",
      "tests/**/*.test.{ts,tsx}",
    ]);
  });
  it("inherits clearMocks from node base", () => {
    expect(jsdomVitestConfig.test?.clearMocks).toBe(true);
  });
});
