diff options
Diffstat (limited to 'test')
86 files changed, 0 insertions, 1743 deletions
diff --git a/test/astro-basic.test.js b/test/astro-basic.test.js deleted file mode 100644 index 89dcf3553..000000000 --- a/test/astro-basic.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Basics = suite('Basic test'); - -setup(Basics, './fixtures/astro-basic'); - -Basics('Can load page', async ({ runtime }) => { - const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); - const $ = doc(result.contents); - - assert.equal($('h1').text(), 'Hello world!'); -}); - -Basics.run(); diff --git a/test/astro-children.test.js b/test/astro-children.test.js deleted file mode 100644 index 368cfc9f9..000000000 --- a/test/astro-children.test.js +++ /dev/null @@ -1,75 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup, setupBuild } from './helpers.js'; - -const ComponentChildren = suite('Component children tests'); - -setup(ComponentChildren, './fixtures/astro-children'); -setupBuild(ComponentChildren, './fixtures/astro-children'); - -ComponentChildren('Passes string children to framework components', async ({ runtime }) => { - let result = await runtime.load('/strings'); - - assert.equal(result.statusCode, 200); - const $ = doc(result.contents); - - const $preact = $('#preact'); - assert.equal($preact.text().trim(), 'Hello world', 'Can pass text to Preact components'); - - const $vue = $('#vue'); - assert.equal($vue.text().trim(), 'Hello world', 'Can pass text to Vue components'); - - const $svelte = $('#svelte'); - assert.equal($svelte.text().trim(), 'Hello world', 'Can pass text to Svelte components'); -}); - -ComponentChildren('Passes markup children to framework components', async ({ runtime }) => { - let result = await runtime.load('/markup'); - - assert.equal(result.statusCode, 200); - const $ = doc(result.contents); - - const $preact = $('#preact > h1'); - assert.equal($preact.text().trim(), 'Hello world', 'Can pass markup to Preact components'); - - const $vue = $('#vue > h1'); - assert.equal($vue.text().trim(), 'Hello world', 'Can pass markup to Vue components'); - - const $svelte = $('#svelte > h1'); - assert.equal($svelte.text().trim(), 'Hello world', 'Can pass markup to Svelte components'); -}); - -ComponentChildren('Passes multiple children to framework components', async ({ runtime }) => { - let result = await runtime.load('/multiple'); - - assert.equal(result.statusCode, 200); - const $ = doc(result.contents); - - const $preact = $('#preact'); - assert.equal($preact.children().length, 2, 'Can pass multiple children to Preact components'); - assert.equal($preact.children(':first-child').text().trim(), 'Hello world'); - assert.equal($preact.children(':last-child').text().trim(), 'Goodbye world'); - - const $vue = $('#vue'); - assert.equal($vue.children().length, 2, 'Can pass multiple children to Vue components'); - assert.equal($vue.children(':first-child').text().trim(), 'Hello world'); - assert.equal($vue.children(':last-child').text().trim(), 'Goodbye world'); - - const $svelte = $('#svelte'); - assert.equal($svelte.children().length, 2, 'Can pass multiple children to Svelte components'); - assert.equal($svelte.children(':first-child').text().trim(), 'Hello world'); - assert.equal($svelte.children(':last-child').text().trim(), 'Goodbye world'); -}); - -ComponentChildren('Can be built', async ({ build }) => { - try { - await build(); - assert.ok(true, 'Can build a project with component children'); - } catch (err) { - console.log(err); - assert.ok(false, 'build threw'); - } -}); - -ComponentChildren.run(); diff --git a/test/astro-collection.test.js b/test/astro-collection.test.js deleted file mode 100644 index 3fdb3b817..000000000 --- a/test/astro-collection.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Collections = suite('Collections'); - -setup(Collections, './fixtures/astro-collection'); - -Collections('generates list & sorts successfully', async ({ runtime }) => { - const result = await runtime.load('/posts'); - const $ = doc(result.contents); - const urls = [ - ...$('#posts a').map(function () { - return $(this).attr('href'); - }), - ]; - assert.equal(urls, ['/post/three', '/post/two']); -}); - -Collections('generates pagination successfully', async ({ runtime }) => { - const result = await runtime.load('/posts'); - const $ = doc(result.contents); - const prev = $('#prev-page'); - const next = $('#next-page'); - assert.equal(prev.length, 0); // this is first page; should be missing - assert.equal(next.length, 1); // this should be on-page -}); - -Collections.run(); diff --git a/test/astro-doctype.test.js b/test/astro-doctype.test.js deleted file mode 100644 index b6c37c3d7..000000000 --- a/test/astro-doctype.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import { fileURLToPath } from 'url'; -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(fileURLToPath(new URL('./fixtures/astro-doctype', import.meta.url))); - - 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-dynamic.test.js b/test/astro-dynamic.test.js deleted file mode 100644 index c3743ddad..000000000 --- a/test/astro-dynamic.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup, setupBuild } from './helpers.js'; - -const DynamicComponents = suite('Dynamic components tests'); - -setup(DynamicComponents, './fixtures/astro-dynamic'); -setupBuild(DynamicComponents, './fixtures/astro-dynamic'); - -DynamicComponents('Loads client-only packages', async ({ runtime }) => { - let result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); - - // Grab the react-dom import - const exp = /import\("(.+?)"\)/g; - let match, reactDomURL; - while ((match = exp.exec(result.contents))) { - if (match[1].includes('react-dom')) { - reactDomURL = match[1]; - } - } - - assert.ok(reactDomURL, 'React dom is on the page'); - - result = await runtime.load(reactDomURL); - assert.equal(result.statusCode, 200, 'Can load react-dom'); -}); - -DynamicComponents('Can be built', async ({ build }) => { - try { - await build(); - assert.ok(true, 'Can build a project with svelte dynamic components'); - } catch (err) { - console.log(err); - assert.ok(false, 'build threw'); - } -}); - -DynamicComponents.run(); diff --git a/test/astro-expr.test.js b/test/astro-expr.test.js deleted file mode 100644 index c3c985712..000000000 --- a/test/astro-expr.test.js +++ /dev/null @@ -1,63 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Expressions = suite('Expressions'); - -setup(Expressions, './fixtures/astro-expr'); - -Expressions('Can load page', async ({ runtime }) => { - const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - - for (let col of ['red', 'yellow', 'blue']) { - assert.equal($('#' + col).length, 1); - } -}); - -Expressions('Ignores characters inside of strings', async ({ runtime }) => { - const result = await runtime.load('/strings'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - - for (let col of ['red', 'yellow', 'blue']) { - assert.equal($('#' + col).length, 1); - } -}); - -Expressions('Ignores characters inside of line comments', async ({ runtime }) => { - const result = await runtime.load('/line-comments'); - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - - for (let col of ['red', 'yellow', 'blue']) { - assert.equal($('#' + col).length, 1); - } -}); - -Expressions('Ignores characters inside of multiline comments', async ({ runtime }) => { - const result = await runtime.load('/multiline-comments'); - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - - for (let col of ['red', 'yellow', 'blue']) { - assert.equal($('#' + col).length, 1); - } -}); - -Expressions('Allows multiple JSX children in mustache', async ({ runtime }) => { - const result = await runtime.load('/multiple-children'); - assert.equal(result.statusCode, 200); - - assert.ok(result.contents.includes('#f') && !result.contents.includes('#t')); -}); - -Expressions.run(); diff --git a/test/astro-fallback.test.js b/test/astro-fallback.test.js deleted file mode 100644 index 2acf29f8e..000000000 --- a/test/astro-fallback.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Fallback = suite('Dynamic component fallback'); - -setup(Fallback, './fixtures/astro-fallback'); - -Fallback('Shows static content', async (context) => { - const result = await context.runtime.load('/'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - assert.equal($('#fallback').text(), 'static'); -}); - -Fallback.run(); diff --git a/test/astro-markdown.test.js b/test/astro-markdown.test.js deleted file mode 100644 index 281243b49..000000000 --- a/test/astro-markdown.test.js +++ /dev/null @@ -1,71 +0,0 @@ -import { existsSync, promises as fsPromises } from 'fs'; -import { join } from 'path'; -import { fileURLToPath } from 'url'; -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { createRuntime } from '../lib/runtime.js'; -import { build } from '../lib/build.js'; -import { loadConfig } from '../lib/config.js'; -import { doc } from './test-utils.js'; - -const { rmdir, readFile } = fsPromises; - -const Markdown = suite('Astro Markdown'); - -let runtime, setupError, fixturePath, astroConfig; - -Markdown.before(async () => { - fixturePath = fileURLToPath(new URL('./fixtures/astro-markdown', import.meta.url)); - - astroConfig = await loadConfig(fixturePath); - - const logging = { - level: 'error', - dest: process.stderr, - }; - - try { - runtime = await createRuntime(astroConfig, { logging }); - } catch (err) { - console.error(err); - setupError = err; - } -}); - -Markdown.after(async () => { - (await runtime) && runtime.shutdown(); - rmdir(join(fixturePath, 'dist'), { recursive: true }); -}); - -Markdown('No errors creating a runtime', () => { - assert.equal(setupError, undefined); -}); - -Markdown('Can load markdown pages with hmx', async () => { - const result = await runtime.load('/post'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - assert.ok($('#first').length, 'There is a div added in markdown'); - assert.ok($('#test').length, 'There is a div added via a component from markdown'); -}); - -Markdown('Can load more complex jsxy stuff', async () => { - const result = await runtime.load('/complex'); - - const $ = doc(result.contents); - const $el = $('#test'); - assert.equal($el.text(), 'Hello world'); -}); - -Markdown('Bundles client-side JS for prod', async () => { - await build(astroConfig); - - const complexHtml = await readFile(join(fixturePath, './dist/complex/index.html'), 'utf-8'); - - assert.match(complexHtml, `import("/_astro/components/Counter.js"`); - assert.ok(existsSync(join(fixturePath, `./dist/_astro/components/Counter.js`)), 'Counter.jsx is bundled for prod'); -}); - -Markdown.run(); diff --git a/test/astro-prettier.test.js b/test/astro-prettier.test.js deleted file mode 100644 index f3d1626c5..000000000 --- a/test/astro-prettier.test.js +++ /dev/null @@ -1,44 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { format } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Prettier = suite('Prettier formatting'); - -setup(Prettier, './fixtures/astro-prettier'); - -/** - * Utility to get `[src, out]` files - * @param name {string} - * @param ctx {any} - */ -const getFiles = async (name, { readFile }) => { - const [src, out] = await Promise.all([readFile(`/in/${name}.astro`), readFile(`/out/${name}.astro`)]); - return [src, out]; -}; - -Prettier('can format a basic Astro file', async (ctx) => { - const [src, out] = await getFiles('basic', ctx); - assert.not.equal(src, out); - - const formatted = format(src); - assert.equal(formatted, out); -}); - -Prettier('can format an Astro file with frontmatter', async (ctx) => { - const [src, out] = await getFiles('frontmatter', ctx); - assert.not.equal(src, out); - - const formatted = format(src); - assert.equal(formatted, out); -}); - -Prettier('can format an Astro file with embedded JSX expressions', async (ctx) => { - const [src, out] = await getFiles('embedded-expr', ctx); - assert.not.equal(src, out); - - const formatted = format(src); - assert.equal(formatted, out); -}); - -Prettier.run(); diff --git a/test/astro-request.test.js b/test/astro-request.test.js deleted file mode 100644 index 1156714dd..000000000 --- a/test/astro-request.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const Request = suite('Astro.request'); - -setup(Request, './fixtures/astro-request'); - -Request('Astro.request available', async (context) => { - const result = await context.runtime.load('/'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - assert.equal($('h1').text(), '/'); -}); - -Request.run(); diff --git a/test/astro-rss.test.js b/test/astro-rss.test.js deleted file mode 100644 index 7b381cb23..000000000 --- a/test/astro-rss.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import fs from 'fs'; -import path from 'path'; -import { execSync } from 'child_process'; -import del from 'del'; -import { fileURLToPath } from 'url'; - -const RSS = suite('RSS Generation'); - -const snapshot = - `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://mysite.dev/feed/episodes.xml</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://mysite.dev/episode/rap-snitch-knishes/</link><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://mysite.dev/episode/fazers/</link><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Thu, 03 Jul 2003 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://mysite.dev/episode/rhymes-like-dimes/</link><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s.\n` + - ']]></description><pubDate>Tue, 19 Oct 1999 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>'; - -const cwd = new URL('./fixtures/astro-rss', import.meta.url); - -const clear = () => del(path.join(fileURLToPath(cwd), 'dist')); // clear dist output - -RSS.before(() => clear()); -RSS.after(() => clear()); - -RSS('Generates RSS correctly', async () => { - execSync('node ../../../astro.mjs build', { cwd: fileURLToPath(cwd) }); - const rss = await fs.promises.readFile(path.join(fileURLToPath(cwd), 'dist', 'feed', 'episodes.xml'), 'utf8'); - assert.match(rss, snapshot); -}); - -RSS.run(); diff --git a/test/astro-scoped-styles.test.js b/test/astro-scoped-styles.test.js deleted file mode 100644 index 295668b84..000000000 --- a/test/astro-scoped-styles.test.js +++ /dev/null @@ -1,34 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { scopeRule } from '../lib/compiler/transform/postcss-scoped-styles/index.js'; - -const ScopedStyles = suite('Astro PostCSS Scoped Styles Plugin'); - -const className = 'astro-abcd1234'; - -ScopedStyles('Scopes rules correctly', () => { - // Note: assume all selectors have no unnecessary spaces (i.e. must be minified) - const tests = { - '.class': `.class.${className}`, - h1: `h1.${className}`, - '.nav h1': `.nav.${className} h1.${className}`, - '.class+.class': `.class.${className}+.class.${className}`, - '.class~:global(a)': `.class.${className}~a`, - '.class *': `.class.${className} .${className}`, - '.class>*': `.class.${className}>.${className}`, - '.class :global(*)': `.class.${className} *`, - '.class :global(.nav:not(.is-active))': `.class.${className} .nav:not(.is-active)`, // preserve nested parens - '.class :global(ul li)': `.class.${className} ul li`, // allow doubly-scoped selectors - '.class:not(.is-active)': `.class.${className}:not(.is-active)`, // Note: the :not() selector can NOT contain multiple classes, so this is correct; if this causes issues for some people then it‘s worth a discussion - 'body h1': `body h1.${className}`, // body shouldn‘t be scoped; it‘s not a component - from: 'from', // ignore keyframe keywords (below) - to: 'to', - '55%': '55%', - }; - - for (const [given, expected] of Object.entries(tests)) { - assert.equal(scopeRule(given, className), expected); - } -}); - -ScopedStyles.run(); diff --git a/test/astro-search.test.js b/test/astro-search.test.js deleted file mode 100644 index 415bc4432..000000000 --- a/test/astro-search.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { setup } from './helpers.js'; - -const Search = suite('Search paths'); - -setup(Search, './fixtures/astro-basic'); - -Search('Finds the root page', async ({ runtime }) => { - const result = await runtime.load('/'); - assert.equal(result.statusCode, 200); -}); - -Search('Matches pathname to filename', async ({ runtime }) => { - const result = await runtime.load('/news'); - assert.equal(result.statusCode, 200); -}); - -Search('A URL with a trailing slash can match a folder with an index.astro', async ({ runtime }) => { - const result = await runtime.load('/nested-astro/'); - assert.equal(result.statusCode, 200); -}); - -Search('A URL with a trailing slash can match a folder with an index.md', async ({ runtime }) => { - const result = await runtime.load('/nested-md/'); - assert.equal(result.statusCode, 200); -}); - -Search('A URL without a trailing slash can redirect to a folder with an index.astro', async ({ runtime }) => { - const result = await runtime.load('/nested-astro'); - assert.equal(result.statusCode, 301); - assert.equal(result.location, '/nested-astro/'); -}); - -Search('A URL without a trailing slash can redirect to a folder with an index.md', async ({ runtime }) => { - const result = await runtime.load('/nested-md'); - assert.equal(result.statusCode, 301); - assert.equal(result.location, '/nested-md/'); -}); - -Search.run(); diff --git a/test/astro-sitemap.test.js b/test/astro-sitemap.test.js deleted file mode 100644 index dccaac326..000000000 --- a/test/astro-sitemap.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import fs from 'fs'; -import path from 'path'; -import { execSync } from 'child_process'; -import del from 'del'; -import { fileURLToPath } from 'url'; - -const Sitemap = suite('Sitemap Generation'); - -const snapshot = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://mysite.dev/episode/fazers/</loc></url><url><loc>https://mysite.dev/episode/rap-snitch-knishes/</loc></url><url><loc>https://mysite.dev/episode/rhymes-like-dimes/</loc></url><url><loc>https://mysite.dev/episodes/</loc></url></urlset>`; - -const cwd = new URL('./fixtures/astro-rss', import.meta.url); - -const clear = () => del(path.join(fileURLToPath(cwd), 'dist')); // clear dist output - -Sitemap.before(() => clear()); -Sitemap.after(() => clear()); - -Sitemap('Generates Sitemap correctly', async () => { - execSync('node ../../../astro.mjs build', { cwd: fileURLToPath(cwd) }); - const rss = await fs.promises.readFile(path.join(fileURLToPath(cwd), 'dist', 'sitemap.xml'), 'utf8'); - assert.match(rss, snapshot); -}); - -Sitemap.run(); diff --git a/test/astro-styles-ssr.test.js b/test/astro-styles-ssr.test.js deleted file mode 100644 index 2fd87b37a..000000000 --- a/test/astro-styles-ssr.test.js +++ /dev/null @@ -1,104 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { doc } from './test-utils.js'; -import { setup } from './helpers.js'; - -const StylesSSR = suite('Styles SSR'); - -/** Basic CSS minification; removes some flakiness in testing CSS */ -function cssMinify(css) { - return css - .trim() // remove whitespace - .replace(/\n\s*/g, '') // collapse lines - .replace(/\s*\{/g, '{') // collapse selectors - .replace(/:\s*/g, ':') // collapse attributes - .replace(/;}/g, '}'); // collapse block -} - -setup(StylesSSR, './fixtures/astro-styles-ssr'); - -StylesSSR('Has <link> tags', async ({ runtime }) => { - const MUST_HAVE_LINK_TAGS = [ - '/_astro/components/ReactCSS.css', - '/_astro/components/ReactModules.module.css', - '/_astro/components/SvelteScoped.svelte.css', - '/_astro/components/VueCSS.vue.css', - '/_astro/components/VueModules.vue.css', - '/_astro/components/VueScoped.vue.css', - ]; - - const result = await runtime.load('/'); - const $ = doc(result.contents); - - for (const href of MUST_HAVE_LINK_TAGS) { - const el = $(`link[href="${href}"]`); - assert.equal(el.length, 1); - } -}); - -StylesSSR('Has correct CSS classes', async ({ runtime }) => { - // TODO: remove this (temporary CI patch) - if (process.version.startsWith('v14.')) { - return; - } - - const result = await runtime.load('/'); - const $ = doc(result.contents); - - const MUST_HAVE_CLASSES = { - '#react-css': 'react-title', - '#react-modules': 'title', // ⚠️ this should be transformed - '#vue-css': 'vue-title', - '#vue-modules': 'title', // ⚠️ this should also be transformed - '#vue-scoped': 'vue-title', // also has data-v-* property - '#svelte-scoped': 'svelte-title', // also has additional class - }; - - for (const [selector, className] of Object.entries(MUST_HAVE_CLASSES)) { - const el = $(selector); - if (selector === '#react-modules' || selector === '#vue-modules') { - // this will generate differently on Unix vs Windows. Here we simply test that it has transformed - assert.match(el.attr('class'), new RegExp(`^_${className}_[A-Za-z0-9-_]+`)); // className should be transformed, surrounded by underscores and other stuff - } else { - // if this is not a CSS module, it should remain as expected - assert.ok(el.attr('class').includes(className)); - } - - // add’l test: Vue Scoped styles should have data-v-* attribute - if (selector === '#vue-scoped') { - const { attribs } = el.get(0); - const scopeId = Object.keys(attribs).find((k) => k.startsWith('data-v-')); - assert.ok(scopeId); - } - - // add’l test: Svelte should have another class - if (selector === '#svelte-title') { - assert.not.equal(el.attr('class'), className); - } - } -}); - -StylesSSR('CSS Module support in .astro', async ({ runtime }) => { - const result = await runtime.load('/'); - const $ = doc(result.contents); - - let scopedClass; - - // test 1: <style> tag in <head> is transformed - const css = cssMinify( - $('style') - .html() - .replace(/\.astro-[A-Za-z0-9-]+/, (match) => { - scopedClass = match; // get class hash from result - return match; - }) - ); - - assert.match(css, `.wrapper${scopedClass}{margin-left:auto;margin-right:auto;max-width:1200px}`); - - // test 2: element received .astro-XXXXXX class (this selector will succeed if transformed correctly) - const wrapper = $(`.wrapper${scopedClass}`); - assert.equal(wrapper.length, 1); -}); - -StylesSSR.run(); diff --git a/test/config-path.test.js b/test/config-path.test.js deleted file mode 100644 index 33e2cf3b7..000000000 --- a/test/config-path.test.js +++ /dev/null @@ -1,24 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { runDevServer } from './helpers.js'; - -const ConfigPath = suite('Config path'); - -const root = new URL('./fixtures/config-path/', import.meta.url); -ConfigPath('can be passed via --config', async (context) => { - const configPath = new URL('./config/my-config.mjs', root).pathname; - const args = ['--config', configPath]; - const process = runDevServer(root, args); - - process.stdout.setEncoding('utf8'); - for await (const chunk of process.stdout) { - if(/Server started/.test(chunk)) { - break; - } - } - - process.kill(); - assert.ok(true, 'Server started'); -}); - -ConfigPath.run(); diff --git a/test/config-port.test.js b/test/config-port.test.js deleted file mode 100644 index e2e238b64..000000000 --- a/test/config-port.test.js +++ /dev/null @@ -1,29 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { runDevServer } from './helpers.js'; -import { loadConfig } from '../lib/config.js'; - -const ConfigPort = suite('Config path'); - -const root = new URL('./fixtures/config-port/', import.meta.url); -ConfigPort('can be specified in the astro config', async (context) => { - const astroConfig = await loadConfig(root.pathname); - assert.equal(astroConfig.devOptions.port, 3001); -}); - -ConfigPort('can be specified via --port flag', async (context) => { - const args = ['--port', '3002']; - const process = runDevServer(root, args); - - process.stdout.setEncoding('utf8'); - for await (const chunk of process.stdout) { - if(/Local:/.test(chunk)) { - assert.ok(/:3002/.test(chunk), 'Using the right port'); - break; - } - } - - process.kill(); -}); - -ConfigPort.run(); diff --git a/test/fixtures/astro-basic/src/layouts/base.astro b/test/fixtures/astro-basic/src/layouts/base.astro deleted file mode 100644 index ec996a32f..000000000 --- a/test/fixtures/astro-basic/src/layouts/base.astro +++ /dev/null @@ -1,17 +0,0 @@ ---- -export let content: any; ---- - -<!doctype html> -<html lang="en"> -<head> - <title>{content.title}</title> - <meta charset="utf-8"> -</head> - -<body> - <h1>{content.title}</h1> - - <main><slot></slot></main> -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-basic/src/pages/index.astro b/test/fixtures/astro-basic/src/pages/index.astro deleted file mode 100644 index 5ae5380c5..000000000 --- a/test/fixtures/astro-basic/src/pages/index.astro +++ /dev/null @@ -1,12 +0,0 @@ ---- -let title = 'My App' ---- - -<html> - <head> - <!-- Head Stuff --> - </head> - <body> - <h1>Hello world!</h1> - </body> -</html> diff --git a/test/fixtures/astro-basic/src/pages/nested-astro/index.astro b/test/fixtures/astro-basic/src/pages/nested-astro/index.astro deleted file mode 100644 index a28992ee6..000000000 --- a/test/fixtures/astro-basic/src/pages/nested-astro/index.astro +++ /dev/null @@ -1,12 +0,0 @@ ---- -let title = 'Nested page' ---- - -<html> - <head> - <!-- Head Stuff --> - </head> - <body> - <h1>{title}</h1> - </body> -</html> diff --git a/test/fixtures/astro-basic/src/pages/nested-md/index.md b/test/fixtures/astro-basic/src/pages/nested-md/index.md deleted file mode 100644 index 23374f9b8..000000000 --- a/test/fixtures/astro-basic/src/pages/nested-md/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: ../../layouts/base.astro -title: My Page ---- - -Hello world
\ No newline at end of file diff --git a/test/fixtures/astro-basic/src/pages/news.astro b/test/fixtures/astro-basic/src/pages/news.astro deleted file mode 100644 index 71a00b8a9..000000000 --- a/test/fixtures/astro-basic/src/pages/news.astro +++ /dev/null @@ -1,12 +0,0 @@ ---- -let title = 'The News' ---- - -<html lang="en"> - <head> - <title>{title}</title> - </head> - <body> - <h1>Hello world!</h1> - </body> -</html> diff --git a/test/fixtures/astro-children/astro.config.mjs b/test/fixtures/astro-children/astro.config.mjs deleted file mode 100644 index e2a209f83..000000000 --- a/test/fixtures/astro-children/astro.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - '.jsx': 'preact' - }, -}; diff --git a/test/fixtures/astro-children/src/components/Component.jsx b/test/fixtures/astro-children/src/components/Component.jsx deleted file mode 100644 index bf9280f86..000000000 --- a/test/fixtures/astro-children/src/components/Component.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function PreactComponent({ children }) { - return <div id="preact">{children}</div> -} diff --git a/test/fixtures/astro-children/src/components/Component.svelte b/test/fixtures/astro-children/src/components/Component.svelte deleted file mode 100644 index 4276a78b8..000000000 --- a/test/fixtures/astro-children/src/components/Component.svelte +++ /dev/null @@ -1,3 +0,0 @@ -<div id="svelte"> - <slot /> -</div> diff --git a/test/fixtures/astro-children/src/components/Component.vue b/test/fixtures/astro-children/src/components/Component.vue deleted file mode 100644 index 22e6e1143..000000000 --- a/test/fixtures/astro-children/src/components/Component.vue +++ /dev/null @@ -1,9 +0,0 @@ -<template> - <div id="vue"> - <slot /> - </div> -</template> - -<script> -export default {} -</script> diff --git a/test/fixtures/astro-children/src/pages/markup.astro b/test/fixtures/astro-children/src/pages/markup.astro deleted file mode 100644 index b771c2433..000000000 --- a/test/fixtures/astro-children/src/pages/markup.astro +++ /dev/null @@ -1,21 +0,0 @@ ---- -import PreactComponent from '../components/Component.jsx'; -import VueComponent from '../components/Component.vue'; -import SvelteComponent from '../components/Component.svelte'; ---- -<html> -<head><title>Children</title></head> -<body> - <PreactComponent> - <h1>Hello world</h1> - </PreactComponent> - - <VueComponent> - <h1>Hello world</h1> - </VueComponent> - - <SvelteComponent> - <h1>Hello world</h1> - </SvelteComponent> -</body> -</html> diff --git a/test/fixtures/astro-children/src/pages/multiple.astro b/test/fixtures/astro-children/src/pages/multiple.astro deleted file mode 100644 index 8c2f73a91..000000000 --- a/test/fixtures/astro-children/src/pages/multiple.astro +++ /dev/null @@ -1,24 +0,0 @@ ---- -import PreactComponent from '../components/Component.jsx'; -import VueComponent from '../components/Component.vue'; -import SvelteComponent from '../components/Component.svelte'; ---- -<html> -<head><title>Children</title></head> -<body> - <PreactComponent> - <h1>Hello world</h1> - <h1>Goodbye world</h1> - </PreactComponent> - - <VueComponent> - <h1>Hello world</h1> - <h1>Goodbye world</h1> - </VueComponent> - - <SvelteComponent> - <h1>Hello world</h1> - <h1>Goodbye world</h1> - </SvelteComponent> -</body> -</html> diff --git a/test/fixtures/astro-children/src/pages/strings.astro b/test/fixtures/astro-children/src/pages/strings.astro deleted file mode 100644 index 10b1a887f..000000000 --- a/test/fixtures/astro-children/src/pages/strings.astro +++ /dev/null @@ -1,21 +0,0 @@ ---- -import PreactComponent from '../components/Component.jsx'; -import VueComponent from '../components/Component.vue'; -import SvelteComponent from '../components/Component.svelte'; ---- -<html> -<head><title>Children</title></head> -<body> - <PreactComponent> - Hello world - </PreactComponent> - - <VueComponent> - Hello world - </VueComponent> - - <SvelteComponent> - Hello world - </SvelteComponent> -</body> -</html> diff --git a/test/fixtures/astro-collection/src/pages/$posts.astro b/test/fixtures/astro-collection/src/pages/$posts.astro deleted file mode 100644 index 4186a9a5c..000000000 --- a/test/fixtures/astro-collection/src/pages/$posts.astro +++ /dev/null @@ -1,28 +0,0 @@ ---- -export let collection: any; - -export async function createCollection() { - return { - async data() { - let data = Astro.fetchContent('./post/*.md'); - data.sort((a, b) => new Date(b.date) - new Date(a.date)); - return data; - }, - pageSize: 2 - }; -} ---- - -<div id="posts"> -{collection.data.map((post) => ( - <article> - <h1>{post.title}</h1> - <a href={post.url}>Read more</a> - </article> -))} -</div> - -<nav> - {collection.url.prev && <a id="prev-page" href={collection.url.prev}>Previous page</a>} - {collection.url.next && <a id="next-page" href={collection.url.next}>Next page</a>} -</nav> diff --git a/test/fixtures/astro-collection/src/pages/post/one.md b/test/fixtures/astro-collection/src/pages/post/one.md deleted file mode 100644 index 9d68e12dd..000000000 --- a/test/fixtures/astro-collection/src/pages/post/one.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Post One -date: 2021-04-13 00:00:00 ---- - -# Post One - -I’m the first blog post diff --git a/test/fixtures/astro-collection/src/pages/post/three.md b/test/fixtures/astro-collection/src/pages/post/three.md deleted file mode 100644 index c495a5195..000000000 --- a/test/fixtures/astro-collection/src/pages/post/three.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Post Three -date: 2021-04-15 00:00:00 ---- - -# Post Three - -I’m the third blog post diff --git a/test/fixtures/astro-collection/src/pages/post/two.md b/test/fixtures/astro-collection/src/pages/post/two.md deleted file mode 100644 index 39855e701..000000000 --- a/test/fixtures/astro-collection/src/pages/post/two.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Post Two -date: 2021-04-14 00:00:00 ---- - -# Post Two - -I’m the second blog post diff --git a/test/fixtures/astro-doctype/src/pages/prepend.astro b/test/fixtures/astro-doctype/src/pages/prepend.astro deleted file mode 100644 index f8fb1bacd..000000000 --- a/test/fixtures/astro-doctype/src/pages/prepend.astro +++ /dev/null @@ -1,8 +0,0 @@ ---- -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/src/pages/preserve.astro b/test/fixtures/astro-doctype/src/pages/preserve.astro deleted file mode 100644 index 3e1ca934f..000000000 --- a/test/fixtures/astro-doctype/src/pages/preserve.astro +++ /dev/null @@ -1,9 +0,0 @@ ---- -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/fixtures/astro-dynamic/astro.config.mjs b/test/fixtures/astro-dynamic/astro.config.mjs deleted file mode 100644 index 09731ba28..000000000 --- a/test/fixtures/astro-dynamic/astro.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - buildOptions: { - sitemap: false, - }, -}; diff --git a/test/fixtures/astro-dynamic/src/components/Counter.jsx b/test/fixtures/astro-dynamic/src/components/Counter.jsx deleted file mode 100644 index 31472c3ac..000000000 --- a/test/fixtures/astro-dynamic/src/components/Counter.jsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; - -export default function() { - return ( - <div> - <button type="button">Increment -</button> - </div> - ) -}
\ No newline at end of file diff --git a/test/fixtures/astro-dynamic/src/components/SvelteCounter.svelte b/test/fixtures/astro-dynamic/src/components/SvelteCounter.svelte deleted file mode 100644 index 8d6b3f5e1..000000000 --- a/test/fixtures/astro-dynamic/src/components/SvelteCounter.svelte +++ /dev/null @@ -1,22 +0,0 @@ - -<script> - let children; - let count = 0; - - function add() { - count += 1; - } - - function subtract() { - count -= 1; - } -</script> - -<div class="counter"> - <button on:click={subtract}>-</button> - <pre>{ count }</pre> - <button on:click={add}>+</button> -</div> -<div class="children"> - <slot /> -</div> diff --git a/test/fixtures/astro-dynamic/src/pages/index.astro b/test/fixtures/astro-dynamic/src/pages/index.astro deleted file mode 100644 index c4d0fef17..000000000 --- a/test/fixtures/astro-dynamic/src/pages/index.astro +++ /dev/null @@ -1,12 +0,0 @@ ---- -import Counter from '../components/Counter.jsx'; -import SvelteCounter from '../components/SvelteCounter.svelte'; ---- -<html> -<head><title>Dynamic pages</title></head> -<body> - <Counter:load /> - - <SvelteCounter:load /> -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-expr/astro.config.mjs b/test/fixtures/astro-expr/astro.config.mjs deleted file mode 100644 index 80d0860c3..000000000 --- a/test/fixtures/astro-expr/astro.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ - -export default { - extensions: { - '.jsx': 'preact' - } -}
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/components/Color.jsx b/test/fixtures/astro-expr/src/components/Color.jsx deleted file mode 100644 index c2681cc9b..000000000 --- a/test/fixtures/astro-expr/src/components/Color.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function({ name }) { - return <div id={name}>{name}</div> -}
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/pages/index.astro b/test/fixtures/astro-expr/src/pages/index.astro deleted file mode 100644 index 50af05d93..000000000 --- a/test/fixtures/astro-expr/src/pages/index.astro +++ /dev/null @@ -1,22 +0,0 @@ ---- -import Color from '../components/Color.jsx'; - -let title = 'My Site'; - -const colors = ['red', 'yellow', 'blue']; ---- - -<html lang="en"> -<head> - <title>My site</title> -</head> -<body> - <h1>{title}</h1> - - {colors.map(color => ( - <div> - <Color name={color} /> - </div> - ))} -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/pages/line-comments.astro b/test/fixtures/astro-expr/src/pages/line-comments.astro deleted file mode 100644 index 2fb7bf643..000000000 --- a/test/fixtures/astro-expr/src/pages/line-comments.astro +++ /dev/null @@ -1,17 +0,0 @@ ---- -let title = 'My App'; - -let colors = ['red', 'yellow', 'blue']; ---- - -<html> -<head> - <title>{title}</title> -</head> -<body> - {colors.map(color => ( - // foo < > < } - <div id={color}>color</div> - ))} -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/pages/multiline-comments.astro b/test/fixtures/astro-expr/src/pages/multiline-comments.astro deleted file mode 100644 index 5c7016ee8..000000000 --- a/test/fixtures/astro-expr/src/pages/multiline-comments.astro +++ /dev/null @@ -1,16 +0,0 @@ ---- -let title = 'My App'; - -let colors = ['red', 'yellow', 'blue']; ---- - -<html> -<head> - <title>{title}</title> -</head> -<body> - {colors.map(color => ( - /* foo < > < } */ <div id={color}>color</div> - ))} -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/pages/multiple-children.astro b/test/fixtures/astro-expr/src/pages/multiple-children.astro deleted file mode 100644 index fb0fafd4a..000000000 --- a/test/fixtures/astro-expr/src/pages/multiple-children.astro +++ /dev/null @@ -1,14 +0,0 @@ ---- -let title = 'My Site'; ---- - -<html lang="en"> -<head> - <title>My site</title> -</head> -<body> - <h1>{title}</h1> - - {false ? <h1>#t</h1> : <h1>#f</h1>} -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-expr/src/pages/strings.astro b/test/fixtures/astro-expr/src/pages/strings.astro deleted file mode 100644 index 712df6120..000000000 --- a/test/fixtures/astro-expr/src/pages/strings.astro +++ /dev/null @@ -1,16 +0,0 @@ ---- -let title = 'My App'; - -let colors = ['red', 'yellow', 'blue']; ---- - -<html> -<head> - <title>{title}</title> -</head> -<body> - {colors.map(color => ( - 'foo < > < }' && <div id={color}>color</div> - ))} -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-fallback/astro.config.mjs b/test/fixtures/astro-fallback/astro.config.mjs deleted file mode 100644 index f50751cfd..000000000 --- a/test/fixtures/astro-fallback/astro.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - '.jsx': 'preact', - }, -}; diff --git a/test/fixtures/astro-fallback/src/components/Client.jsx b/test/fixtures/astro-fallback/src/components/Client.jsx deleted file mode 100644 index d79536e27..000000000 --- a/test/fixtures/astro-fallback/src/components/Client.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import { h } from 'preact'; - -export default function(props) { - return ( - <div id="fallback">{import.meta.env.astro ? 'static' : 'dynamic'}</div> - ); -};
\ No newline at end of file diff --git a/test/fixtures/astro-fallback/src/pages/index.astro b/test/fixtures/astro-fallback/src/pages/index.astro deleted file mode 100644 index f4f20c322..000000000 --- a/test/fixtures/astro-fallback/src/pages/index.astro +++ /dev/null @@ -1,16 +0,0 @@ ---- -import Client from '../components/Client.jsx'; - -let title = 'My Page' ---- - -<html> -<head> - <title>{title}</title> -</head> -<body> - <h1>{title}</h1> - - <Client:load /> -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-markdown/astro.config.mjs b/test/fixtures/astro-markdown/astro.config.mjs deleted file mode 100644 index c8631c503..000000000 --- a/test/fixtures/astro-markdown/astro.config.mjs +++ /dev/null @@ -1,8 +0,0 @@ -export default { - extensions: { - '.jsx': 'preact', - }, - buildOptions: { - sitemap: false, - }, -}; diff --git a/test/fixtures/astro-markdown/src/components/Counter.jsx b/test/fixtures/astro-markdown/src/components/Counter.jsx deleted file mode 100644 index a75f858b5..000000000 --- a/test/fixtures/astro-markdown/src/components/Counter.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import { h } from 'preact'; -import { useState } from 'preact/hooks'; - -export default function () { - const [count, setCount] = useState(0); - return <button onClick={() => setCount(count + 1)}>{count}</button>; -} diff --git a/test/fixtures/astro-markdown/src/components/Example.jsx b/test/fixtures/astro-markdown/src/components/Example.jsx deleted file mode 100644 index 57bde3a95..000000000 --- a/test/fixtures/astro-markdown/src/components/Example.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function() { - return <div id="test">Testing</div> -}
\ No newline at end of file diff --git a/test/fixtures/astro-markdown/src/components/Hello.jsx b/test/fixtures/astro-markdown/src/components/Hello.jsx deleted file mode 100644 index 787ca587b..000000000 --- a/test/fixtures/astro-markdown/src/components/Hello.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function({ name }) { - return <div id="test">Hello {name}</div> -}
\ No newline at end of file diff --git a/test/fixtures/astro-markdown/src/layouts/content.astro b/test/fixtures/astro-markdown/src/layouts/content.astro deleted file mode 100644 index 925a243a9..000000000 --- a/test/fixtures/astro-markdown/src/layouts/content.astro +++ /dev/null @@ -1,10 +0,0 @@ -<html> - <head> - <!-- Head Stuff --> - </head> - <body> - <div class="container"> - <slot></slot> - </div> - </body> -</html> diff --git a/test/fixtures/astro-markdown/src/pages/complex.md b/test/fixtures/astro-markdown/src/pages/complex.md deleted file mode 100644 index 6367948b9..000000000 --- a/test/fixtures/astro-markdown/src/pages/complex.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: ../layouts/content.astro -title: My Blog Post -description: This is a post about some stuff. -import: - Hello: '../components/Hello.jsx' - Counter: '../components/Counter.jsx' ---- - -## Interesting Topic - -<Hello name={`world`} /> -<Counter:load />
\ No newline at end of file diff --git a/test/fixtures/astro-markdown/src/pages/post.md b/test/fixtures/astro-markdown/src/pages/post.md deleted file mode 100644 index 58ebdc945..000000000 --- a/test/fixtures/astro-markdown/src/pages/post.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: ../layouts/content.astro -title: My Blog Post -description: This is a post about some stuff. -import: - Example: '../components/Example.jsx' ---- - -## Interesting Topic - -<div id="first">Some content</div> - -<Example /> diff --git a/test/fixtures/astro-prettier/in/basic.astro b/test/fixtures/astro-prettier/in/basic.astro deleted file mode 100644 index 33be82226..000000000 --- a/test/fixtures/astro-prettier/in/basic.astro +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE html> - <html lang="en"> -<head> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Document</title> -</head> - <body> - <h1> - Hello world!</h1> - </body> -</html> diff --git a/test/fixtures/astro-prettier/in/embedded-expr.astro b/test/fixtures/astro-prettier/in/embedded-expr.astro deleted file mode 100644 index 842da6578..000000000 --- a/test/fixtures/astro-prettier/in/embedded-expr.astro +++ /dev/null @@ -1,26 +0,0 @@ ---- - import Color from '../components/Color.jsx'; - - let title = - 'My Site'; - - const colors = ['red', 'yellow', 'blue',]; ---- - - - - - -<html lang="en"> - <head> - <title>My site</title> - </head> - <body> - <h1>{title}</h1> - - {"I'm some super long text and oh boy I sure do hope this formatter doesn't break me!"} - - {colors.map(color => ( - <div><Color name={color} /></div>))} - </body> -</html> diff --git a/test/fixtures/astro-prettier/in/frontmatter.astro b/test/fixtures/astro-prettier/in/frontmatter.astro deleted file mode 100644 index 58cfcf698..000000000 --- a/test/fixtures/astro-prettier/in/frontmatter.astro +++ /dev/null @@ -1,18 +0,0 @@ ---- - import Color from '../components/Color.jsx'; - - let title = - 'My Site'; - - const colors = ['red', 'yellow', 'blue',]; ---- - - -<html lang="en"> - <head> - <title>My site</title> - </head> - <body> - <h1>{title}</h1> - </body> -</html> diff --git a/test/fixtures/astro-prettier/out/basic.astro b/test/fixtures/astro-prettier/out/basic.astro deleted file mode 100644 index c77d2735b..000000000 --- a/test/fixtures/astro-prettier/out/basic.astro +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Document</title> - </head> - <body> - <h1>Hello world!</h1> - </body> -</html> diff --git a/test/fixtures/astro-prettier/out/embedded-expr.astro b/test/fixtures/astro-prettier/out/embedded-expr.astro deleted file mode 100644 index 0ae01ff3f..000000000 --- a/test/fixtures/astro-prettier/out/embedded-expr.astro +++ /dev/null @@ -1,24 +0,0 @@ ---- -import Color from "../components/Color.jsx"; - -let title = "My Site"; - -const colors = ["red", "yellow", "blue"]; ---- - -<html lang="en"> - <head> - <title>My site</title> - </head> - <body> - <h1>{title}</h1> - - {"I'm some super long text and oh boy I sure do hope this formatter doesn't break me!"} - - {colors.map((color) => ( - <div> - <Color name={color} /> - </div> - ))} - </body> -</html> diff --git a/test/fixtures/astro-prettier/out/frontmatter.astro b/test/fixtures/astro-prettier/out/frontmatter.astro deleted file mode 100644 index e2a9ad0ba..000000000 --- a/test/fixtures/astro-prettier/out/frontmatter.astro +++ /dev/null @@ -1,16 +0,0 @@ ---- -import Color from "../components/Color.jsx"; - -let title = "My Site"; - -const colors = ["red", "yellow", "blue"]; ---- - -<html lang="en"> - <head> - <title>My site</title> - </head> - <body> - <h1>{title}</h1> - </body> -</html> diff --git a/test/fixtures/astro-request/src/pages/index.astro b/test/fixtures/astro-request/src/pages/index.astro deleted file mode 100644 index f809a76e3..000000000 --- a/test/fixtures/astro-request/src/pages/index.astro +++ /dev/null @@ -1,10 +0,0 @@ ---- -let path = Astro.request.url.pathname; ---- - -<html> -<head><title>Test</title></head> -<body> - <h1>{path}</h1> -</body> -</html>
\ No newline at end of file diff --git a/test/fixtures/astro-rss/astro.config.mjs b/test/fixtures/astro-rss/astro.config.mjs deleted file mode 100644 index c19ba79f1..000000000 --- a/test/fixtures/astro-rss/astro.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - buildOptions: { - site: 'https://mysite.dev', - }, -}; diff --git a/test/fixtures/astro-rss/src/pages/$episodes.astro b/test/fixtures/astro-rss/src/pages/$episodes.astro deleted file mode 100644 index 686770480..000000000 --- a/test/fixtures/astro-rss/src/pages/$episodes.astro +++ /dev/null @@ -1,40 +0,0 @@ ---- -export let collection; - -export async function createCollection() { - return { - async data() { - const episodes = Astro.fetchContent('./episode/*.md'); - episodes.sort((a, b) => new Date(b.pubDate) - new Date(a.pubDate)); - return episodes; - }, - rss: { - title: 'MF Doomcast', - description: 'The podcast about the things you find on a picnic, or at a picnic table', - xmlns: { - itunes: 'http://www.itunes.com/dtds/podcast-1.0.dtd', - content: 'http://purl.org/rss/1.0/modules/content/', - }, - customData: `<language>en-us</language>` + - `<itunes:author>MF Doom</itunes:author>`, - item: (item) => ({ - title: item.title, - link: item.url, - description: item.description, - pubDate: item.pubDate + 'Z', - customData: `<itunes:episodeType>${item.type}</itunes:episodeType>` + - `<itunes:duration>${item.duration}</itunes:duration>` + - `<itunes:explicit>${item.explicit || false}</itunes:explicit>`, - }), - } - } -} ---- - -<html> - <head> - <title>Podcast Episodes</title> - <link rel="alternate" type="application/rss+2.0" href="/feed/episodes.xml" /> - </head> - <body></body> -</html> diff --git a/test/fixtures/astro-rss/src/pages/episode/fazers.md b/test/fixtures/astro-rss/src/pages/episode/fazers.md deleted file mode 100644 index 9efbf1fa2..000000000 --- a/test/fixtures/astro-rss/src/pages/episode/fazers.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Fazers -artist: King Geedorah -type: music -duration: 197 -pubDate: '2003-07-03 00:00:00' -description: Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade” -explicit: true ---- - -# Fazers - -Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade” diff --git a/test/fixtures/astro-rss/src/pages/episode/rap-snitch-knishes.md b/test/fixtures/astro-rss/src/pages/episode/rap-snitch-knishes.md deleted file mode 100644 index e7ade24b4..000000000 --- a/test/fixtures/astro-rss/src/pages/episode/rap-snitch-knishes.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Rap Snitch Knishes (feat. Mr. Fantastik) -artist: MF Doom -type: music -duration: 172 -pubDate: '2004-11-16 00:00:00' -description: Complex named this song the “22nd funniest rap song of all time.” -explicit: true ---- - -# Rap Snitch Knishes (feat. Mr. Fantastik) - -Complex named this song the “22nd funniest rap song of all time.” diff --git a/test/fixtures/astro-rss/src/pages/episode/rhymes-like-dimes.md b/test/fixtures/astro-rss/src/pages/episode/rhymes-like-dimes.md deleted file mode 100644 index ba73c28d8..000000000 --- a/test/fixtures/astro-rss/src/pages/episode/rhymes-like-dimes.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Rhymes Like Dimes (feat. Cucumber Slice) -artist: MF Doom -type: music -duration: 259 -pubDate: '1999-10-19 00:00:00' -description: | - Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s. -explicit: true ---- - -# Rhymes Like Dimes (feat. Cucumber Slice) - -Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s. diff --git a/test/fixtures/astro-styles-ssr/src/components/ReactCSS.css b/test/fixtures/astro-styles-ssr/src/components/ReactCSS.css deleted file mode 100644 index a29595b86..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/ReactCSS.css +++ /dev/null @@ -1,3 +0,0 @@ -.react-title { - font-family: fantasy; -} diff --git a/test/fixtures/astro-styles-ssr/src/components/ReactCSS.jsx b/test/fixtures/astro-styles-ssr/src/components/ReactCSS.jsx deleted file mode 100644 index 88d731a3f..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/ReactCSS.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import './ReactCSS.css'; - -function ReactCSS() { - return ( - <h1 id="react-css" className="react-title"> - React Global CSS - </h1> - ); -} -export default ReactCSS; diff --git a/test/fixtures/astro-styles-ssr/src/components/ReactModules.jsx b/test/fixtures/astro-styles-ssr/src/components/ReactModules.jsx deleted file mode 100644 index b3aef6bb2..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/ReactModules.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import Styles from './ReactModules.module.css'; - -function ReactModules() { - return ( - <h1 id="react-modules" className={Styles.title}> - React Modules - </h1> - ); -} -export default ReactModules; diff --git a/test/fixtures/astro-styles-ssr/src/components/ReactModules.module.css b/test/fixtures/astro-styles-ssr/src/components/ReactModules.module.css deleted file mode 100644 index 465178859..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/ReactModules.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.title { - font-family: fantasy; -} diff --git a/test/fixtures/astro-styles-ssr/src/components/SvelteScoped.svelte b/test/fixtures/astro-styles-ssr/src/components/SvelteScoped.svelte deleted file mode 100644 index 8c2b7d451..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/SvelteScoped.svelte +++ /dev/null @@ -1,7 +0,0 @@ -<h1 id="svelte-scoped" class="svelte-title">Svelte Scoped CSS</h1> - -<style> - .svelte-title { - font-family: 'Comic Sans MS', sans-serif; - } -</style> diff --git a/test/fixtures/astro-styles-ssr/src/components/VueCSS.vue b/test/fixtures/astro-styles-ssr/src/components/VueCSS.vue deleted file mode 100644 index 23ac9a291..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/VueCSS.vue +++ /dev/null @@ -1,9 +0,0 @@ -<style> -.vue-title { - font-family: cursive; -} -</style> - -<template> - <h1 id="vue-css" class="vue-title">Vue Global CSS</h1> -</template> diff --git a/test/fixtures/astro-styles-ssr/src/components/VueModules.vue b/test/fixtures/astro-styles-ssr/src/components/VueModules.vue deleted file mode 100644 index bd520fec4..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/VueModules.vue +++ /dev/null @@ -1,9 +0,0 @@ -<style module> -.title { - font-family: cursive; -} -</style> - -<template> - <h1 id="vue-modules" :class="$style.title">Vue CSS Modules</h1> -</template> diff --git a/test/fixtures/astro-styles-ssr/src/components/VueScoped.vue b/test/fixtures/astro-styles-ssr/src/components/VueScoped.vue deleted file mode 100644 index 0eee4dff1..000000000 --- a/test/fixtures/astro-styles-ssr/src/components/VueScoped.vue +++ /dev/null @@ -1,9 +0,0 @@ -<style scoped> -.vue-title { - font-family: cursive; -} -</style> - -<template> - <h1 id="vue-scoped" class="vue-title">Vue Scoped CSS</h1> -</template> diff --git a/test/fixtures/astro-styles-ssr/src/pages/index.astro b/test/fixtures/astro-styles-ssr/src/pages/index.astro deleted file mode 100644 index 45f9683ac..000000000 --- a/test/fixtures/astro-styles-ssr/src/pages/index.astro +++ /dev/null @@ -1,31 +0,0 @@ ---- -import ReactCSS from '../components/ReactCSS.jsx'; -import ReactModules from '../components/ReactModules.jsx'; -import VueCSS from '../components/VueCSS.vue'; -import VueScoped from '../components/VueScoped.vue'; -import VueModules from '../components/VueModules.vue'; -import SvelteScoped from '../components/SvelteScoped.svelte'; ---- - -<html> - <head> - <meta charset="UTF-8" /> - <style lang="scss"> - .wrapper { - margin-left: auto; - margin-right: auto; - max-width: 1200px; - } - </style> - </head> - <body> - <div class="wrapper"> - <ReactCSS /> - <ReactModules /> - <VueCSS /> - <VueScoped /> - <VueModules /> - <SvelteScoped /> - </div> - </body> -</html> diff --git a/test/fixtures/config-path/config/my-config.mjs b/test/fixtures/config-path/config/my-config.mjs deleted file mode 100644 index f50751cfd..000000000 --- a/test/fixtures/config-path/config/my-config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - '.jsx': 'preact', - }, -}; diff --git a/test/fixtures/config-port/astro.config.mjs b/test/fixtures/config-port/astro.config.mjs deleted file mode 100644 index 61858cdae..000000000 --- a/test/fixtures/config-port/astro.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ - -export default { - devOptions: { - port: 3001 - } -}
\ No newline at end of file diff --git a/test/fixtures/react-component/src/components/Goodbye.vue b/test/fixtures/react-component/src/components/Goodbye.vue deleted file mode 100644 index 430dfdb71..000000000 --- a/test/fixtures/react-component/src/components/Goodbye.vue +++ /dev/null @@ -1,11 +0,0 @@ -<template> - <h2 id="vue-h2">Hasta la vista, {{ name }}</h2> -</template> - -<script> -export default { - props: { - name: String, - }, -}; -</script> diff --git a/test/fixtures/react-component/src/components/Hello.jsx b/test/fixtures/react-component/src/components/Hello.jsx deleted file mode 100644 index 4b6c416a9..000000000 --- a/test/fixtures/react-component/src/components/Hello.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react'; - -export default function ({ name }) { - return <h2 id="react-h2">Hello {name}!</h2>; -} diff --git a/test/fixtures/react-component/src/pages/index.astro b/test/fixtures/react-component/src/pages/index.astro deleted file mode 100644 index 74475f34e..000000000 --- a/test/fixtures/react-component/src/pages/index.astro +++ /dev/null @@ -1,14 +0,0 @@ ---- -import Hello from '../components/Hello.jsx'; -import Later from '../components/Goodbye.vue'; // use different specifier ---- - -<html> - <head> - <!-- Head Stuff --> - </head> - <body> - <Hello name="world" /> - <Later name="baby" /> - </body> -</html> diff --git a/test/helpers.js b/test/helpers.js deleted file mode 100644 index b14005563..000000000 --- a/test/helpers.js +++ /dev/null @@ -1,73 +0,0 @@ -import { fileURLToPath } from 'url'; -import { build as astroBuild } from '../lib/build.js'; -import { readFile } from 'fs/promises'; -import { createRuntime } from '../lib/runtime.js'; -import { loadConfig } from '../lib/config.js'; -import * as assert from 'uvu/assert'; -import execa from 'execa'; - -/** setup fixtures for tests */ -export function setup(Suite, fixturePath) { - let runtime, setupError; - - Suite.before(async (context) => { - const astroConfig = await loadConfig(fileURLToPath(new URL(fixturePath, import.meta.url))); - - const logging = { - level: 'error', - dest: process.stderr, - }; - - try { - runtime = await createRuntime(astroConfig, { logging }); - } catch (err) { - console.error(err); - setupError = err; - } - - context.runtime = runtime; - context.readFile = async (path) => { - const resolved = fileURLToPath(new URL(`${fixturePath}${path}`, import.meta.url)); - return readFile(resolved).then((r) => r.toString('utf-8')); - }; - }); - - Suite.after(async () => { - (await runtime) && runtime.shutdown(); - }); - - Suite('No errors creating a runtime', () => { - assert.equal(setupError, undefined); - }); -} - -export function setupBuild(Suite, fixturePath) { - let build, setupError; - - Suite.before(async (context) => { - const astroConfig = await loadConfig(fileURLToPath(new URL(fixturePath, import.meta.url))); - - const logging = { - level: 'error', - dest: process.stderr, - }; - - build = (...args) => astroBuild(astroConfig, ...args); - context.build = build; - }); - - Suite.after(async () => { - // Shutdown i guess. - }); - - Suite('No errors creating a runtime', () => { - assert.equal(setupError, undefined); - }); -} - -const cliURL = new URL('../astro.mjs', import.meta.url); -export function runDevServer(root, additionalArgs = []) { - const args = [cliURL.pathname, 'dev', '--project-root', root.pathname].concat(additionalArgs); - const proc = execa('node', args); - return proc; -}
\ No newline at end of file diff --git a/test/react-component.test.js b/test/react-component.test.js deleted file mode 100644 index 7de92cb0a..000000000 --- a/test/react-component.test.js +++ /dev/null @@ -1,54 +0,0 @@ -import { fileURLToPath } from 'url'; -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 React = suite('React Components'); - -let runtime, setupError; - -React.before(async () => { - const astroConfig = await loadConfig(fileURLToPath(new URL('./fixtures/react-component', import.meta.url))); - - const logging = { - level: 'error', - dest: process.stderr, - }; - - try { - runtime = await createRuntime(astroConfig, { logging }); - } catch (err) { - console.error(err); - setupError = err; - } -}); - -React.after(async () => { - (await runtime) && runtime.shutdown(); -}); - -React('No error creating the runtime', () => { - assert.equal(setupError, undefined); -}); - -React('Can load React', async () => { - const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - assert.equal($('#react-h2').text(), 'Hello world!'); -}); - -React('Can load Vue', async () => { - const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); - - const $ = doc(result.contents); - assert.equal($('#vue-h2').text(), 'Hasta la vista, baby'); -}); - -React.run(); diff --git a/test/snowpack-integration.test.js b/test/snowpack-integration.test.js deleted file mode 100644 index eff5b6756..000000000 --- a/test/snowpack-integration.test.js +++ /dev/null @@ -1,91 +0,0 @@ -import { fileURLToPath } from 'url'; -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { createRuntime } from '../lib/runtime.js'; -import { loadConfig } from '../lib/config.js'; -import { promises as fsPromises } from 'fs'; -import { relative as pathRelative } from 'path'; - -const { readdir, stat } = fsPromises; - -const SnowpackDev = suite('snowpack.dev'); - -let runtime, cwd, setupError; - -SnowpackDev.before(async () => { - // Bug: Snowpack config is still loaded relative to the current working directory. - cwd = process.cwd(); - process.chdir(fileURLToPath(new URL('../examples/snowpack/', import.meta.url))); - - const astroConfig = await loadConfig(fileURLToPath(new URL('../examples/snowpack', import.meta.url))); - - const logging = { - level: 'error', - dest: process.stderr, - }; - - try { - runtime = await createRuntime(astroConfig, { logging }); - } catch (err) { - // eslint-disable-next-line no-console - console.error(err); - setupError = err; - } -}); - -SnowpackDev.after(async () => { - process.chdir(cwd); - (await runtime) && runtime.shutdown(); -}); -/** create an iterator for all page files */ -async function* allPageFiles(root) { - for (const filename of await readdir(root)) { - const fullpath = new URL(filename, root); - const info = await stat(fullpath); - - if (info.isDirectory()) { - yield* allPageFiles(new URL(fullpath + '/')); - } else { - yield fullpath; - } - } -} -/** create an iterator for all pages and yield the relative paths */ -async function* allPages(root) { - for await (let fileURL of allPageFiles(root)) { - let bare = fileURLToPath(fileURL) - .replace(/\.(astro|md)$/, '') - .replace(/index$/, ''); - - yield '/' + pathRelative(fileURLToPath(root), bare); - } -} - -SnowpackDev('No error creating the runtime', () => { - assert.equal(setupError, undefined); -}); - -SnowpackDev('Can load every page', async () => { - const failed = []; - - const pageRoot = new URL('../examples/snowpack/src/pages/', import.meta.url); - for await (let pathname of allPages(pageRoot)) { - if (pathname.includes('proof-of-concept-dynamic')) { - continue; - } - const result = await runtime.load(pathname); - if (result.statusCode === 500) { - failed.push({ ...result, pathname }); - continue; - } - assert.equal(result.statusCode, 200, `Loading ${pathname}`); - } - - if (failed.length > 0) { - // eslint-disable-next-line no-console - console.error(failed); - } - assert.equal(failed.length, 0, 'Failed pages'); -}); - -SnowpackDev.run(); diff --git a/test/test-utils.js b/test/test-utils.js deleted file mode 100644 index 6a71d834a..000000000 --- a/test/test-utils.js +++ /dev/null @@ -1,18 +0,0 @@ -import cheerio from 'cheerio'; -import prettier from 'prettier'; -import { fileURLToPath } from 'url'; -/** load html */ -export function doc(html) { - return cheerio.load(html); -} - -/** - * format the contents of an astro file - * @param contents {string} - */ -export function format(contents) { - return prettier.format(contents, { - parser: 'astro', - plugins: [fileURLToPath(new URL('../prettier-plugin-astro', import.meta.url))], - }); -} |