2023-07-03 12:59:43 +00:00
|
|
|
/* Deno types consider DOM elements nullable */
|
|
|
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
2022-10-07 13:38:38 +00:00
|
|
|
import { DOMParser } from 'https://deno.land/x/deno_dom@v0.1.35-alpha/deno-dom-wasm.ts';
|
|
|
|
import { assert, assertEquals } from 'https://deno.land/std@0.158.0/testing/asserts.ts';
|
2023-06-05 07:05:16 +00:00
|
|
|
import { runBuildAndStartAppFromSubprocess } from './helpers.ts';
|
2022-10-07 13:36:24 +00:00
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
name: 'Dynamic import',
|
2023-06-05 07:05:16 +00:00
|
|
|
async fn(t) {
|
|
|
|
const app = await runBuildAndStartAppFromSubprocess('./fixtures/dynimport/');
|
|
|
|
|
|
|
|
await t.step('Works', async () => {
|
|
|
|
const resp = await fetch(app.url);
|
2022-10-07 13:36:24 +00:00
|
|
|
assertEquals(resp.status, 200);
|
|
|
|
const html = await resp.text();
|
|
|
|
assert(html);
|
|
|
|
const doc = new DOMParser().parseFromString(html, `text/html`);
|
|
|
|
const div = doc!.querySelector('#thing');
|
|
|
|
assert(div, 'div exists');
|
|
|
|
});
|
2023-06-05 07:05:16 +00:00
|
|
|
|
|
|
|
app.stop();
|
2022-10-07 13:36:24 +00:00
|
|
|
},
|
|
|
|
});
|