2021-03-19 21:07:45 +00:00
|
|
|
import { suite } from 'uvu';
|
|
|
|
import * as assert from 'uvu/assert';
|
|
|
|
import { createRuntime } from '../lib/runtime.js';
|
|
|
|
import { doc } from './test-utils.js';
|
|
|
|
|
|
|
|
const Basics = suite('HMX Basics');
|
|
|
|
|
|
|
|
let runtime;
|
|
|
|
|
|
|
|
Basics.before(async () => {
|
|
|
|
const astroConfig = {
|
2021-03-24 15:45:38 +00:00
|
|
|
projectRoot: new URL('./fixtures/astro-basic/', import.meta.url),
|
|
|
|
hmxRoot: new URL('./fixtures/astro-basic/astro/', import.meta.url),
|
2021-03-19 21:07:45 +00:00
|
|
|
dist: './_site'
|
|
|
|
};
|
|
|
|
|
|
|
|
const logging = {
|
|
|
|
level: 'error',
|
|
|
|
dest: process.stderr
|
|
|
|
};
|
|
|
|
|
|
|
|
runtime = await createRuntime(astroConfig, logging);
|
|
|
|
});
|
|
|
|
|
|
|
|
Basics.after(async () => {
|
2021-03-23 04:34:32 +00:00
|
|
|
await runtime && runtime.shutdown();
|
2021-03-19 21:07:45 +00:00
|
|
|
});
|
|
|
|
|
2021-03-24 15:45:38 +00:00
|
|
|
Basics('Can load page', async () => {
|
2021-03-19 21:07:45 +00:00
|
|
|
const result = await runtime.load('/');
|
|
|
|
|
|
|
|
assert.equal(result.statusCode, 200);
|
|
|
|
const $ = doc(result.contents);
|
|
|
|
|
|
|
|
assert.equal($('h1').text(), 'Hello world!');
|
|
|
|
});
|
|
|
|
|
|
|
|
Basics.run();
|