Skip to content

Commit

Permalink
handle extensions correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 6, 2024
1 parent e362a14 commit f472811
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,21 @@ it("should throw an error when requesting a non-existent file", async () => {
await expect(importTemplate("e.js")).rejects.toThrowError();
await expect(importConcat("e.js")).rejects.toThrowError();
});

it("should support dynamic requests without the extension", async () => {
expect(requireTemplate("a")).toBe(a);
expect(requireConcat("a")).toBe(a);
expect(requireTemplate("d")).toBe("d");
expect(requireConcat("d")).toBe("d");
await expect(importTemplate("a")).resolves.toBe(a);
await expect(importTemplate("d")).resolves.toHaveProperty("default", "d");
await expect(importConcat("a")).resolves.toBe(a);
await expect(importConcat("d")).resolves.toHaveProperty("default", "d");
});

it("should not support dynamic requests with double extension", async () => {
await expect(importTemplateSuffix("a.js")).rejects.toThrowError();
await expect(importTemplateSuffix("d.js")).rejects.toThrowError();
await expect(importConcatSuffix("a.js")).rejects.toThrowError();
await expect(importConcatSuffix("d.js")).rejects.toThrowError();
});

0 comments on commit f472811

Please sign in to comment.