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