diff --git a/__tests__/base/emit.test.ts b/__tests__/base/emit.test.ts index aa805e6a..34bc8019 100644 --- a/__tests__/base/emit.test.ts +++ b/__tests__/base/emit.test.ts @@ -91,6 +91,14 @@ describe('relative base emit', () => { expect(html).toMatch(/href="\.\/assets\/style\.[\w-]+\.css"/) }) + test('locale 404 renders at its own depth', () => { + const html = read('relative', 'zh/404.html') + expect(html).toContain( + 'window.__VP_SITE_ROOT__=new URL("../",location).href' + ) + expect(html).toMatch(/href="\.\.\/assets\/style\.[\w-]+\.css"/) + }) + test('no sentinel leaks into emitted html or css', () => { for (const file of walk(dist('relative'))) { if (!/\.(html|css)$/.test(file)) continue @@ -208,3 +216,44 @@ describe('plain base emit is unchanged', () => { expect(html).not.toContain('crossorigin>') }) }) + +describe('not-found emit', () => { + for (const mode of ['plain', 'relative', 'cdn', 'mpa']) { + test(`${mode}: the theme page stands in for a missing root 404.md`, () => { + const html = read(mode, '404.html') + expect(html).toContain('
') + expect(html).toContain('class="NotFound"') + expect(html).toContain('404 | Base Fixture') + expect(html).toContain('') + expect(html).toContain(' { + const html = read(mode, 'zh/404.html') + expect(html).toContain('
') + expect(html).toContain('页面未找到') + expect(html).toContain('页面未找到 | Base Fixture') + expect(html).toContain('') + expect(html).toContain(' { + const sitemap = read(mode, 'sitemap.xml') + expect(sitemap).toContain('https://example.com/zh/') + expect(sitemap).toContain('https://example.com/sub/page.html') + expect(sitemap).not.toContain('404.html') + }) + } + + test('mpa: the not-found page needs no script', () => { + const html = read('mpa', '404.html') + expect(html).not.toContain('