|
| 1 | +import { assertEquals, assertStringIncludes } from "jsr:@std/assert"; |
| 2 | + |
| 3 | +Deno.test("issue #1217 - CSS files should resolve through package.json exports", async () => { |
| 4 | + // Test case 1: yet-another-react-lightbox |
| 5 | + // The package.json has: "./styles.css": {"default": "./dist/styles.css"} |
| 6 | + // Should redirect from /styles.css to /dist/styles.css |
| 7 | + const res1 = await fetch( |
| 8 | + "http://localhost:8080/*yet-another-react-lightbox@3.21.7/styles.css", |
| 9 | + { redirect: "follow" }, |
| 10 | + ); |
| 11 | + const css1 = await res1.text(); |
| 12 | + assertEquals(res1.ok, true, "yet-another-react-lightbox styles.css should be found"); |
| 13 | + assertEquals(res1.status, 200, "Should return 200 OK"); |
| 14 | + assertStringIncludes(res1.url, "/dist/styles.css", "Should resolve to /dist/styles.css"); |
| 15 | + assertStringIncludes(css1, "yarl__", "Should contain lightbox CSS"); |
| 16 | + |
| 17 | + // Test case 2: react-tweet |
| 18 | + // The package.json has: "./theme.css": "./dist/twitter-theme/theme.css" |
| 19 | + // Should redirect from /theme.css to /dist/twitter-theme/theme.css |
| 20 | + const res2 = await fetch( |
| 21 | + "http://localhost:8080/*react-tweet@3.2.2/theme.css", |
| 22 | + { redirect: "follow" }, |
| 23 | + ); |
| 24 | + const css2 = await res2.text(); |
| 25 | + assertEquals(res2.ok, true, "react-tweet theme.css should be found"); |
| 26 | + assertEquals(res2.status, 200, "Should return 200 OK"); |
| 27 | + assertStringIncludes(res2.url, "/dist/twitter-theme/theme.css", "Should resolve to /dist/twitter-theme/theme.css"); |
| 28 | + assertStringIncludes(css2, "tweet", "Should contain tweet CSS"); |
| 29 | +}); |
0 commit comments