Skip to content

Commit

Permalink
remove internal test for sake of simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 6, 2024
1 parent 6870354 commit 235b667
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions test/resolve.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { existsSync } from "node:fs";
import { describe, it, expect, vi, afterEach } from "vitest";
import { describe, it, expect } from "vitest";
import { resolveSync, resolvePathSync, fileURLToPath } from "../src";
import { parseFilename } from "ufo";

const tests = [
// Resolve to path
Expand All @@ -15,44 +14,6 @@ const tests = [
{ input: "/non/existent", action: "throws" },
] as const;

afterEach(() => {
vi.restoreAllMocks();
});

const { mockedResolve } = await vi.hoisted(async () => {
const importMetaResolve = await vi.importActual<
Record<string, (...args: unknown[]) => unknown>
>("import-meta-resolve");
return {
mockedResolve: vi.fn((id, url, conditions) => {
return importMetaResolve.moduleResolve(id, url, conditions);
}),
};
});

vi.mock("import-meta-resolve", () => {
return {
moduleResolve: mockedResolve,
};
});

describe("tryModuleResolve", () => {
it("should create correct url", () => {
expect(() =>
resolvePathSync("tslib/", {
url: import.meta.url.replace(
parseFilename(import.meta.url, { strict: false }) || "",
"",
),
}),
).toThrow();
expect(mockedResolve).toHaveBeenCalled();
expect(
mockedResolve.mock.calls.some((call) => call[0].includes("//")),
).toBe(false);
});
});

describe("resolveSync", () => {
for (const test of tests) {
it(`${test.input} should ${test.action}`, () => {
Expand Down

0 comments on commit 235b667

Please sign in to comment.