// This doesn't really belong here since it's testing something in the
// root workspace, but we don't have testing configured for that and I'm
// not adding it just for this one test.

import fs from "node:fs/promises";

describe("Yarn path", () => {
  it("should use same yarn path for both configuration files", async () => {
    const privateYarnConfigPath = require.resolve("../../../.yarnrc.yml");
    const publicYarnConfigPath = require.resolve("../../../.yarnrc.yml.npm");

    const [privateYarnConfig, publicYarnConfig] = await Promise.all([
      fs.readFile(privateYarnConfigPath, "utf8"),
      fs.readFile(publicYarnConfigPath, "utf8"),
    ]);

    const privateYarnPath = privateYarnConfig.match(/yarnPath: (.*)/)?.[1];
    const publicYarnPath = publicYarnConfig.match(/yarnPath: (.*)/)?.[1];

    expect(privateYarnPath).toBe(publicYarnPath);
  });
});
