summaryrefslogtreecommitdiff
path: root/packages/integrations/deno/test/basics.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-04-15 17:01:33 -0400
committerGravatar GitHub <noreply@github.com> 2022-04-15 17:01:33 -0400
commite5383cd3576f858bf65f6d460de397c4f2dae208 (patch)
tree16a21fae7bcf521cf1a11226eb0bf5e8a1ec52d8 /packages/integrations/deno/test/basics.test.js
parentb0ba22c5ffab6575706ae904d0ad8cadc3f48d43 (diff)
downloadastro-e5383cd3576f858bf65f6d460de397c4f2dae208.tar.gz
astro-e5383cd3576f858bf65f6d460de397c4f2dae208.tar.zst
astro-e5383cd3576f858bf65f6d460de397c4f2dae208.zip
Handle static file serving in Deno adapter's start command (#3121)
* Handle static file serving in Deno adapter's start command * Adds a changeset * Ignore a .ts imort
Diffstat (limited to 'packages/integrations/deno/test/basics.test.js')
-rw-r--r--packages/integrations/deno/test/basics.test.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/packages/integrations/deno/test/basics.test.js b/packages/integrations/deno/test/basics.test.js
index 6f152d4f4..6efb3b0d5 100644
--- a/packages/integrations/deno/test/basics.test.js
+++ b/packages/integrations/deno/test/basics.test.js
@@ -1,10 +1,14 @@
import { runBuildAndStartApp } from './helpers.js';
-import { assertEquals, assert } from './deps.js';
+import { assertEquals, assert, DOMParser } from './deps.js';
+
+async function startApp(cb) {
+ await runBuildAndStartApp('./fixtures/basics/', cb);
+}
Deno.test({
name: 'Basics',
async fn() {
- await runBuildAndStartApp('./fixtures/basics/', async () => {
+ await startApp(async () => {
const resp = await fetch('http://127.0.0.1:8085/');
assertEquals(resp.status, 200);
const html = await resp.text();
@@ -12,3 +16,23 @@ Deno.test({
});
},
});
+
+Deno.test({
+ name: 'Loads style assets',
+ async fn() {
+ await startApp(async () => {
+ let resp = await fetch('http://127.0.0.1:8085/');
+ const html = await resp.text();
+
+ const doc = new DOMParser().parseFromString(html, `text/html`);
+ const link = doc.querySelector('link');
+ const href = link.getAttribute('href');
+
+ resp = await fetch(new URL(href, 'http://127.0.0.1:8085/'));
+ assertEquals(resp.status, 200);
+ const ct = resp.headers.get('content-type');
+ assertEquals(ct, 'text/css');
+ await resp.body.cancel()
+ });
+ }
+})