|
| 1 | +import { assert, assertEquals, assertStringIncludes } from "jsr:@std/assert"; |
| 2 | + |
| 3 | +Deno.test( |
| 4 | + "bundle json", |
| 5 | + async () => { |
| 6 | + const res = await fetch("http://localhost:8080/cli-spinners@3.2.1/denonext/cli-spinners.mjs"); |
| 7 | + const text = await res.text(); |
| 8 | + assert(res.ok); |
| 9 | + assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8"); |
| 10 | + assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable"); |
| 11 | + assertStringIncludes(text, `dots:{interval:80,frames:[`); |
| 12 | + }, |
| 13 | +); |
| 14 | + |
| 15 | +Deno.test( |
| 16 | + "import mod from 'url' with { type: 'json' }", |
| 17 | + async () => { |
| 18 | + const res = await fetch("http://localhost:8080/cli-spinners@3.2.1/denonext/cli-spinners.nobundle.mjs"); |
| 19 | + const text = await res.text(); |
| 20 | + assert(res.ok); |
| 21 | + assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8"); |
| 22 | + assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable"); |
| 23 | + assertStringIncludes(text, `from"/cli-spinners@3.2.1/spinners.json"with{type:"json"}`); |
| 24 | + }, |
| 25 | +); |
| 26 | + |
| 27 | +Deno.test( |
| 28 | + "import(url, { type: 'json' })", |
| 29 | + async () => { |
| 30 | + const res = await fetch("http://localhost:8080/aleman@1.1.0/es2022/menu/menu.mjs"); |
| 31 | + const text = await res.text(); |
| 32 | + assert(res.ok); |
| 33 | + assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8"); |
| 34 | + assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable"); |
| 35 | + assertStringIncludes(text, `import("/aleman@1.1.0/menu/importmap.json?module")`); |
| 36 | + }, |
| 37 | +); |
| 38 | + |
| 39 | +Deno.test( |
| 40 | + "json?module", |
| 41 | + async () => { |
| 42 | + const res = await fetch("http://localhost:8080/aleman@1.1.0/menu/importmap.json?module"); |
| 43 | + const text = await res.text(); |
| 44 | + assert(res.ok); |
| 45 | + assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8"); |
| 46 | + assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable"); |
| 47 | + }, |
| 48 | +); |
0 commit comments