Skip to content

Commit

Permalink
test: fix esm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luxass committed Feb 15, 2025
1 parent 59800d9 commit 513051c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,21 @@ it("should return a URL for a module with worker option", () => {

it("should return typescript types from headers when URL is a string", async () => {
const types = await resolveESMTypes("https://esm.sh/[email protected]");
expect(types).toContain("/@types/react@~18.3/index.d.ts");
expect(types).not.toBeNull();

const url = new URL(types!);

expect(url.hostname).toBe("esm.sh");
expect(url.pathname).toMatch(/^\/@types\/react@~18\.3\.\d+\/index\.d\.ts$/);
});

it("should return typescript types from headers when URL is a URL object", async () => {
const types = await resolveESMTypes(new URL("https://esm.sh/[email protected]"));
expect(types).toBe("https://esm.sh/v128/@types/react@~18.2/index.d.ts");

const url = new URL(types!);

expect(url.hostname).toBe("esm.sh");
expect(url.pathname).toMatch(/^\/@types\/react@~18\.2\.\d+\/index\.d\.ts$/);
});

it("should return null when x-typescript-types header is not present", async () => {
Expand Down

0 comments on commit 513051c

Please sign in to comment.