diff options
Diffstat (limited to 'packages/astro/test/svelte-component.test.js')
-rw-r--r-- | packages/astro/test/svelte-component.test.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/packages/astro/test/svelte-component.test.js b/packages/astro/test/svelte-component.test.js new file mode 100644 index 000000000..16ccd0e0b --- /dev/null +++ b/packages/astro/test/svelte-component.test.js @@ -0,0 +1,61 @@ +import assert from 'node:assert/strict'; +import { after, before, describe, it } from 'node:test'; +import * as cheerio from 'cheerio'; +import { isWindows, loadFixture } from './test-utils.js'; + +describe('Svelte component', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/svelte-component/', + }); + }); + + describe('build', () => { + before(async () => { + await fixture.build(); + }); + + it('Works with TypeScript', async () => { + const html = await fixture.readFile('/typescript/index.html'); + const $ = cheerio.load(html); + + assert.equal($('#svelte-ts').text(), 'Hello, TypeScript'); + }); + + it('Works with custom Svelte config', async () => { + const html = await fixture.readFile('/typescript/index.html'); + const $ = cheerio.load(html); + + assert.equal($('#svelte-custom-ext').text(), 'Hello, Custom Extensions'); + }); + }); + + if (isWindows) return; + + describe('dev', () => { + let devServer; + + before(async () => { + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer.stop(); + }); + + it('scripts proxy correctly', async () => { + const html = await fixture.fetch('/').then((res) => res.text()); + const $ = cheerio.load(html); + + for (const script of $('script').toArray()) { + const { src } = script.attribs; + + if (!src) continue; + + assert.equal((await fixture.fetch(src)).status, `404: ${src}`, 200); + } + }); + }); +}); |