0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
Emanuele Stoppa 4c93bd8154
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>
2023-07-17 15:53:10 +01:00

36 lines
1 KiB
TypeScript

import { loadFixture } from './test-utils.ts';
import { assertEquals, assert, DOMParser } from './deps.ts';
Deno.env.set('SECRET_STUFF', 'secret');
Deno.test({
ignore: true,
name: 'Edge Basics',
permissions: 'inherit',
async fn(t) {
const fixture = loadFixture('./fixtures/edge-basic/');
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 envDiv = doc.querySelector('#env');
assertEquals(envDiv?.innerText, 'secret');
});
await t.step('Clean up', async () => {
await fixture.cleanup();
});
},
});