-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy path404.test.mjs
More file actions
42 lines (31 loc) · 1.27 KB
/
404.test.mjs
File metadata and controls
42 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { buildNotFoundPage } from '../404.mjs';
describe('buildNotFoundPage', () => {
it('uses a `404` head with a "Page Not Found" heading', () => {
const { head } = buildNotFoundPage();
assert.equal(head.api, '404');
assert.equal(head.path, '/404');
assert.equal(head.basename, '404');
assert.equal(head.heading.data.name, 'Page Not Found');
});
it('produces a single synthetic entry with a not-found paragraph', () => {
const { entries } = buildNotFoundPage();
assert.equal(entries.length, 1);
const paragraph = entries[0].content.children.find(
child => child.type === 'paragraph'
);
assert.ok(paragraph, 'expected a paragraph node in the content tree');
assert.match(paragraph.children[0].value, /could not be found/);
});
it('places the head heading at the start of the content tree', () => {
const { head, entries } = buildNotFoundPage();
assert.equal(entries[0].content.children[0], head.heading);
});
it('returns the same shape on every call', () => {
const a = buildNotFoundPage();
const b = buildNotFoundPage();
assert.deepEqual(a.head, b.head);
assert.equal(a.entries.length, b.entries.length);
});
});