summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
diff options
context:
space:
mode:
authorGravatar Emanuele Stoppa <my.burning@gmail.com> 2023-07-17 15:53:10 +0100
committerGravatar GitHub <noreply@github.com> 2023-07-17 15:53:10 +0100
commit4c93bd8154c210ebce6ad2889bd8bfdf4c349a78 (patch)
treee0b9fb9474845411b35f177260408f444d0631ff /packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
parentcc8e9de88179d2ed4b70980c60b41448db393429 (diff)
downloadastro-4c93bd8154c210ebce6ad2889bd8bfdf4c349a78.tar.gz
astro-4c93bd8154c210ebce6ad2889bd8bfdf4c349a78.tar.zst
astro-4c93bd8154c210ebce6ad2889bd8bfdf4c349a78.zip
feat(@astrojs/netlify): edge middleware support (#7632)
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/netlify/test/edge-functions/edge-basic.test.ts')
-rw-r--r--packages/integrations/netlify/test/edge-functions/edge-basic.test.ts40
1 files changed, 22 insertions, 18 deletions
diff --git a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
index 9f2a7bde3..699ab0014 100644
--- a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
+++ b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
@@ -3,30 +3,34 @@ import { assertEquals, assert, DOMParser } from './deps.ts';
Deno.env.set('SECRET_STUFF', 'secret');
-// @ts-expect-error
Deno.test({
- // TODO: debug why build cannot be found in "await import"
ignore: true,
name: 'Edge Basics',
- skip: true,
- async fn() {
+ permissions: 'inherit',
+ async fn(t) {
const fixture = loadFixture('./fixtures/edge-basic/');
- await fixture.runBuild();
- const { default: handler } = await import(
- './fixtures/edge-basic/.netlify/edge-functions/entry.js'
- );
- const response = await handler(new Request('http://example.com/'));
- assertEquals(response.status, 200);
- const html = await response.text();
- assert(html, 'got some html');
+ await t.step('Run the build', async () => {
+ await fixture.runBuild();
+ });
+ await t.step('Should correctly render the response', async () => {
+ const { default: handler } = await import(
+ './fixtures/edge-basic/.netlify/edge-functions/entry.js'
+ );
+ const response = await handler(new Request('http://example.com/'));
+ assertEquals(response.status, 200);
+ const html = await response.text();
+ assert(html, 'got some html');
- const doc = new DOMParser().parseFromString(html, `text/html`)!;
- const div = doc.querySelector('#react');
- assert(div, 'div exists');
+ const doc = new DOMParser().parseFromString(html, `text/html`)!;
+ const div = doc.querySelector('#react');
+ assert(div, 'div exists');
- const envDiv = doc.querySelector('#env');
- assertEquals(envDiv?.innerText, 'secret');
+ const envDiv = doc.querySelector('#env');
+ assertEquals(envDiv?.innerText, 'secret');
+ });
- await fixture.cleanup();
+ await t.step('Clean up', async () => {
+ await fixture.cleanup();
+ });
},
});