diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/astro-basic.test.js | 9 | ||||
-rw-r--r-- | test/astro-doctype.test.js | 54 | ||||
-rw-r--r-- | test/astro-markdown.test.js | 2 | ||||
-rw-r--r-- | test/astro-styles-ssr.test.js | 2 | ||||
-rw-r--r-- | test/fixtures/astro-doctype/astro.config.mjs | 5 | ||||
-rw-r--r-- | test/fixtures/astro-doctype/astro/pages/prepend.astro | 8 | ||||
-rw-r--r-- | test/fixtures/astro-doctype/astro/pages/preserve.astro | 9 | ||||
-rw-r--r-- | test/react-component.test.js | 2 | ||||
-rw-r--r-- | test/snowpack-integration.test.js | 2 |
9 files changed, 83 insertions, 10 deletions
diff --git a/test/astro-basic.test.js b/test/astro-basic.test.js index 79b71cfa7..606a94679 100644 --- a/test/astro-basic.test.js +++ b/test/astro-basic.test.js @@ -1,6 +1,7 @@ import { suite } from 'uvu'; import * as assert from 'uvu/assert'; import { createRuntime } from '../lib/runtime.js'; +import { loadConfig } from '../lib/config.js'; import { doc } from './test-utils.js'; const Basics = suite('HMX Basics'); @@ -8,18 +9,14 @@ const Basics = suite('HMX Basics'); let runtime; Basics.before(async () => { - const astroConfig = { - projectRoot: new URL('./fixtures/astro-basic/', import.meta.url), - hmxRoot: new URL('./fixtures/astro-basic/astro/', import.meta.url), - dist: './_site', - }; + const astroConfig = await loadConfig(new URL('./fixtures/astro-basics', import.meta.url).pathname); const logging = { level: 'error', dest: process.stderr, }; - runtime = await createRuntime(astroConfig, logging); + runtime = await createRuntime(astroConfig, {logging}); }); Basics.after(async () => { diff --git a/test/astro-doctype.test.js b/test/astro-doctype.test.js new file mode 100644 index 000000000..23188fd97 --- /dev/null +++ b/test/astro-doctype.test.js @@ -0,0 +1,54 @@ +import { suite } from 'uvu'; +import * as assert from 'uvu/assert'; +import { loadConfig } from '../lib/config.js'; +import { createRuntime } from '../lib/runtime.js'; + +const DType = suite('doctype'); + +let runtime, setupError; + +DType.before(async () => { + try { + const astroConfig = await loadConfig(new URL('./fixtures/astro-doctype', import.meta.url).pathname); + + const logging = { + level: 'error', + dest: process.stderr, + }; + + + runtime = await createRuntime(astroConfig, {logging}); + } catch (err) { + console.error(err); + setupError = err; + } +}); + +DType.after(async () => { + (await runtime) && runtime.shutdown(); +}); + +DType('No errors creating a runtime', () => { + assert.equal(setupError, undefined); +}); + +DType('Automatically prepends the standards mode doctype', async () => { + const result = await runtime.load('/prepend'); + + assert.equal(result.statusCode, 200); + + const html = result.contents.toString('utf-8'); + assert.ok(html.startsWith('<!doctype html>'), 'Doctype always included'); +}); + +DType.skip('Preserves user provided doctype', async () => { + const result = await runtime.load('/preserve'); + + assert.equal(result.statusCode, 200); + + const html = result.contents.toString('utf-8'); + assert.ok(html.startsWith('<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'), + 'Doctype included was preserved'); +}); + +DType.run(); diff --git a/test/astro-markdown.test.js b/test/astro-markdown.test.js index cbab25e36..7f5b310e3 100644 --- a/test/astro-markdown.test.js +++ b/test/astro-markdown.test.js @@ -17,7 +17,7 @@ Markdown.before(async () => { }; try { - runtime = await createRuntime(astroConfig, logging); + runtime = await createRuntime(astroConfig, {logging}); } catch (err) { console.error(err); setupError = err; diff --git a/test/astro-styles-ssr.test.js b/test/astro-styles-ssr.test.js index 69fa68353..27da41049 100644 --- a/test/astro-styles-ssr.test.js +++ b/test/astro-styles-ssr.test.js @@ -16,7 +16,7 @@ StylesSSR.before(async () => { dest: process.stderr, }; - runtime = await createRuntime(astroConfig, logging); + runtime = await createRuntime(astroConfig, {logging}); }); StylesSSR.after(async () => { diff --git a/test/fixtures/astro-doctype/astro.config.mjs b/test/fixtures/astro-doctype/astro.config.mjs new file mode 100644 index 000000000..c7cbdb435 --- /dev/null +++ b/test/fixtures/astro-doctype/astro.config.mjs @@ -0,0 +1,5 @@ +export default { + projectRoot: '.', + astroRoot: './astro', + dist: './_site', +}; diff --git a/test/fixtures/astro-doctype/astro/pages/prepend.astro b/test/fixtures/astro-doctype/astro/pages/prepend.astro new file mode 100644 index 000000000..f8fb1bacd --- /dev/null +++ b/test/fixtures/astro-doctype/astro/pages/prepend.astro @@ -0,0 +1,8 @@ +--- +let title = 'My Site'; +--- + +<html lang="en"> + <head><title>{title}</title></head> + <body><h1>Hello world</h1></body> +</html>
\ No newline at end of file diff --git a/test/fixtures/astro-doctype/astro/pages/preserve.astro b/test/fixtures/astro-doctype/astro/pages/preserve.astro new file mode 100644 index 000000000..3e1ca934f --- /dev/null +++ b/test/fixtures/astro-doctype/astro/pages/preserve.astro @@ -0,0 +1,9 @@ +--- +let title = 'My Site'; +--- + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> + <head><title>{title}</title></head> + <body><h1>Hello world</h1></body> +</html>
\ No newline at end of file diff --git a/test/react-component.test.js b/test/react-component.test.js index 85892a623..48608f902 100644 --- a/test/react-component.test.js +++ b/test/react-component.test.js @@ -17,7 +17,7 @@ React.before(async () => { }; try { - runtime = await createRuntime(astroConfig, logging); + runtime = await createRuntime(astroConfig, {logging}); } catch (err) { console.error(err); setupError = err; diff --git a/test/snowpack-integration.test.js b/test/snowpack-integration.test.js index 097550d39..ba2c509c0 100644 --- a/test/snowpack-integration.test.js +++ b/test/snowpack-integration.test.js @@ -25,7 +25,7 @@ SnowpackDev.before(async () => { }; try { - runtime = await createRuntime(astroConfig, logging); + runtime = await createRuntime(astroConfig, {logging}); } catch (err) { console.error(err); setupError = err; |