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');
|
|
|
|
|
2023-03-07 13:41:24 +00:00
|
|
|
// @ts-expect-error
|
2022-04-19 15:22:15 +00:00
|
|
|
Deno.test({
|
2022-06-17 00:31:08 +00:00
|
|
|
// TODO: debug why build cannot be found in "await import"
|
|
|
|
ignore: true,
|
2022-04-19 15:22:15 +00:00
|
|
|
name: 'Edge Basics',
|
2022-06-21 12:32:05 +00:00
|
|
|
skip: true,
|
2022-04-19 15:22:15 +00:00
|
|
|
async fn() {
|
2023-05-17 13:23:20 +00:00
|
|
|
const fixture = loadFixture('./fixtures/edge-basic/');
|
|
|
|
await fixture.runBuild();
|
2022-06-17 00:32:29 +00:00
|
|
|
const { default: handler } = await import(
|
|
|
|
'./fixtures/edge-basic/.netlify/edge-functions/entry.js'
|
|
|
|
);
|
2022-04-19 15:22:15 +00:00
|
|
|
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
|
|
|
|
|
|
|
const doc = new DOMParser().parseFromString(html, `text/html`)!;
|
|
|
|
const div = doc.querySelector('#react');
|
|
|
|
assert(div, 'div exists');
|
|
|
|
|
2022-11-08 13:54:49 +00:00
|
|
|
const envDiv = doc.querySelector('#env');
|
|
|
|
assertEquals(envDiv?.innerText, 'secret');
|
|
|
|
|
2023-05-17 13:23:20 +00:00
|
|
|
await fixture.cleanup();
|
2022-04-19 15:22:15 +00:00
|
|
|
},
|
|
|
|
});
|