Skip to content

Commit

Permalink
test: add outsidebase test
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 12, 2023
1 parent d1efcf7 commit be0ef83
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions playground/assets/__tests__/assets.spec.ts
Expand Up @@ -8,6 +8,7 @@ import {
getBg,
getColor,
isBuild,
isServe,
listAssets,
notifyRebuildComplete,
page,
Expand Down Expand Up @@ -60,6 +61,22 @@ test('should fallback to index.html when accessing non-existant html file', asyn
expect((await fetchPath('doesnt-exist.html')).status).toBe(200)
})

describe.runIf(isServe)('outside base', () => {
test('should get a 404 with html', async () => {
const res = await fetch(new URL('/baz', viteTestUrl), {
headers: { Accept: 'text/html,*/*' },
})
expect(res.status).toBe(404)
expect(res.headers.get('Content-Type')).toBe('text/html')
})

test('should get a 404 with text', async () => {
const res = await fetch(new URL('/baz', viteTestUrl))
expect(res.status).toBe(404)
expect(res.headers.get('Content-Type')).toBe('text/plain')
})
})

describe('injected scripts', () => {
test('@vite/client', async () => {
const hasClient = await page.$(
Expand Down

0 comments on commit be0ef83

Please sign in to comment.