2022-03-30 07:42:19 -05:00
|
|
|
import { runBuildAndStartApp } from './helpers.js';
|
2022-04-15 16:01:33 -05:00
|
|
|
import { assertEquals, assert, DOMParser } from './deps.js';
|
|
|
|
|
|
|
|
async function startApp(cb) {
|
|
|
|
await runBuildAndStartApp('./fixtures/basics/', cb);
|
|
|
|
}
|
2022-03-30 07:42:19 -05:00
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
name: 'Basics',
|
|
|
|
async fn() {
|
2022-04-15 16:01:33 -05:00
|
|
|
await startApp(async () => {
|
2022-03-30 07:42:19 -05:00
|
|
|
const resp = await fetch('http://127.0.0.1:8085/');
|
|
|
|
assertEquals(resp.status, 200);
|
|
|
|
const html = await resp.text();
|
|
|
|
assert(html);
|
|
|
|
});
|
2022-03-30 07:43:13 -05:00
|
|
|
},
|
2022-03-30 07:42:19 -05:00
|
|
|
});
|
2022-04-15 16:01:33 -05:00
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
name: 'Loads style assets',
|
|
|
|
async fn() {
|
|
|
|
await startApp(async () => {
|
|
|
|
let resp = await fetch('http://127.0.0.1:8085/');
|
|
|
|
const html = await resp.text();
|
|
|
|
|
|
|
|
const doc = new DOMParser().parseFromString(html, `text/html`);
|
|
|
|
const link = doc.querySelector('link');
|
|
|
|
const href = link.getAttribute('href');
|
2022-04-15 16:02:19 -05:00
|
|
|
|
2022-04-15 16:01:33 -05:00
|
|
|
resp = await fetch(new URL(href, 'http://127.0.0.1:8085/'));
|
|
|
|
assertEquals(resp.status, 200);
|
|
|
|
const ct = resp.headers.get('content-type');
|
|
|
|
assertEquals(ct, 'text/css');
|
2022-04-15 16:02:19 -05:00
|
|
|
await resp.body.cancel();
|
2022-04-15 16:01:33 -05:00
|
|
|
});
|
2022-04-15 16:02:19 -05:00
|
|
|
},
|
|
|
|
});
|