import { fileURLToPath } from "node:url";
import path from "node:path";

import getTargets from "../../lib/index.js";

const oldCwd = process.cwd();

beforeAll(() => {
  process.chdir(path.dirname(fileURLToPath(import.meta.url)));
});

afterAll(() => {
  process.chdir(oldCwd);
});

it("loads browserslistrc", () => {
  const actual = getTargets({}, {});

  expect(actual).toEqual({ chrome: "4.0.0" });
});

it("loads browserslistrc and respects browserslistEnv", () => {
  const actual = getTargets(
    {},
    {
      browserslistEnv: "development",
    },
  );

  expect(actual).toEqual({ chrome: "88.0.0" });
});
