2023-05-17 13:23:20 +00:00
|
|
|
import { loadFixture } from './test-utils.ts';
|
2022-04-21 16:10:06 +00:00
|
|
|
import { assertEquals, assert, DOMParser } from './deps.ts';
|
2022-04-19 15:22:15 +00:00
|
|
|
|
2022-11-08 13:54:49 +00:00
|
|
|
Deno.env.set('SECRET_STUFF', 'secret');
|
|
|
|
|
2022-04-19 15:22:15 +00:00
|
|
|
Deno.test({
|
2022-06-17 00:31:08 +00:00
|
|
|
ignore: true,
|
2022-04-19 15:22:15 +00:00
|
|
|
name: 'Edge Basics',
|
2023-07-17 14:53:10 +00:00
|
|
|
permissions: 'inherit',
|
|
|
|
async fn(t) {
|
2023-05-17 13:23:20 +00:00
|
|
|
const fixture = loadFixture('./fixtures/edge-basic/');
|
2023-07-17 14:53:10 +00:00
|
|
|
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');
|
2022-04-21 16:10:06 +00:00
|
|
|
|
2023-07-17 14:53:10 +00:00
|
|
|
const doc = new DOMParser().parseFromString(html, `text/html`)!;
|
|
|
|
const div = doc.querySelector('#react');
|
|
|
|
assert(div, 'div exists');
|
2022-04-21 16:10:06 +00:00
|
|
|
|
2023-07-17 14:53:10 +00:00
|
|
|
const envDiv = doc.querySelector('#env');
|
|
|
|
assertEquals(envDiv?.innerText, 'secret');
|
|
|
|
});
|
2022-11-08 13:54:49 +00:00
|
|
|
|
2023-07-17 14:53:10 +00:00
|
|
|
await t.step('Clean up', async () => {
|
|
|
|
await fixture.cleanup();
|
|
|
|
});
|
2022-04-19 15:22:15 +00:00
|
|
|
},
|
|
|
|
});
|