diff options
author | 2022-10-07 15:36:24 +0200 | |
---|---|---|
committer | 2022-10-07 09:36:24 -0400 | |
commit | 5bbe385b21597f240eafc989c8909768ca96a65a (patch) | |
tree | 00866d7978e0513ff2389cf85c54b82c8f6edb14 /packages/integrations/deno/test/basics.test.js | |
parent | f38e5560851759323854b70c7a5277ba9bf05710 (diff) | |
download | astro-5bbe385b21597f240eafc989c8909768ca96a65a.tar.gz astro-5bbe385b21597f240eafc989c8909768ca96a65a.tar.zst astro-5bbe385b21597f240eafc989c8909768ca96a65a.zip |
Improve test infrastructure for integrations/deno (#5005)
* Improve test infrastructure for integrations/deno
* Add changeset
* Use declared type
* Remove changeset
* Upgrade deno version in -workflow
Diffstat (limited to 'packages/integrations/deno/test/basics.test.js')
-rw-r--r-- | packages/integrations/deno/test/basics.test.js | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/packages/integrations/deno/test/basics.test.js b/packages/integrations/deno/test/basics.test.js deleted file mode 100644 index c883fc8ae..000000000 --- a/packages/integrations/deno/test/basics.test.js +++ /dev/null @@ -1,104 +0,0 @@ -import { runBuildAndStartApp } from './helpers.js'; -import { assertEquals, assert, DOMParser } from './deps.js'; - -async function startApp(cb) { - await runBuildAndStartApp('./fixtures/basics/', cb); -} - -// this needs to be here and not in the specific test case, because -// the variables are loaded in the global scope of the built server -// module, which is only executed once upon the first load -const varContent = 'this is a value stored in env variable'; -Deno.env.set('SOME_VARIABLE', varContent); - -Deno.test({ - name: 'Basics', - async fn() { - await startApp(async () => { - const resp = await fetch('http://127.0.0.1:8085/'); - assertEquals(resp.status, 200); - const html = await resp.text(); - assert(html); - const doc = new DOMParser().parseFromString(html, `text/html`); - const div = doc.querySelector('#react'); - assert(div, 'div exists'); - }); - }, -}); - -Deno.test({ - name: 'Custom 404', - async fn() { - await startApp(async () => { - const resp = await fetch('http://127.0.0.1:8085/this-does-not-exist'); - assertEquals(resp.status, 404); - const html = await resp.text(); - assert(html); - const doc = new DOMParser().parseFromString(html, `text/html`); - const header = doc.querySelector('#custom-404'); - assert(header, 'displays custom 404'); - }); - }, -}); - -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(); - }); - }, -}); - -Deno.test({ - name: 'Correctly loads run-time env variables', - async fn() { - await startApp(async () => { - const resp = await fetch('http://127.0.0.1:8085/'); - const html = await resp.text(); - - const doc = new DOMParser().parseFromString(html, `text/html`); - const p = doc.querySelector('p#env-value'); - assertEquals(p.innerText, varContent); - }); - }, -}); - -Deno.test({ - name: 'Works with Markdown', - async fn() { - await startApp(async () => { - const resp = await fetch('http://127.0.0.1:8085/markdown'); - const html = await resp.text(); - - const doc = new DOMParser().parseFromString(html, `text/html`); - const h1 = doc.querySelector('h1'); - assertEquals(h1.innerText, 'Heading from Markdown'); - }); - }, -}); - -Deno.test({ - name: 'Works with MDX', - async fn() { - await startApp(async () => { - const resp = await fetch('http://127.0.0.1:8085/mdx'); - const html = await resp.text(); - - const doc = new DOMParser().parseFromString(html, `text/html`); - const h1 = doc.querySelector('h1'); - assertEquals(h1.innerText, 'Heading from MDX'); - }); - }, -}); |