diff --git a/test/resolve.test.ts b/test/resolve.test.ts index 13cd5ee6..e23750bd 100644 --- a/test/resolve.test.ts +++ b/test/resolve.test.ts @@ -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 @@ -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 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}`, () => {