1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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();
});
},
});
|