Skip to content

Commit de8fd1c

Browse files
committed
test(llms-txt): cover building the pages' Markdown
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9dfcee2 commit de8fd1c

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
4+
import { u } from 'unist-builder';
5+
6+
import { buildPages } from '../buildPages.mjs';
7+
8+
const entry = (path, text, extra = {}) => ({
9+
path,
10+
content: u('root', [u('paragraph', [u('text', text)])]),
11+
...extra,
12+
});
13+
14+
describe('buildPages', () => {
15+
it('joins the content of the entries of each page, in order', () => {
16+
const pages = buildPages([
17+
entry('/a', 'First.'),
18+
entry('/b', 'Other.'),
19+
entry('/a', 'Second.'),
20+
]);
21+
22+
assert.deepEqual(pages, [
23+
{ path: '/a', markdown: 'First.\n\nSecond.\n' },
24+
{ path: '/b', markdown: 'Other.\n' },
25+
]);
26+
});
27+
28+
it('leaves out pages generated by other generators', () => {
29+
assert.deepEqual(
30+
buildPages([entry('/all', 'All.', { synthetic: true })]),
31+
[]
32+
);
33+
});
34+
});

0 commit comments

Comments
 (0)