-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathmarkdown.test.mjs
More file actions
52 lines (41 loc) · 1.34 KB
/
markdown.test.mjs
File metadata and controls
52 lines (41 loc) · 1.34 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
43
44
45
46
47
48
49
50
51
52
'use strict';
import assert from 'node:assert/strict';
import { describe, it, mock } from 'node:test';
import dedent from 'dedent';
let content;
mock.module('../../utils/parser.mjs', {
namedExports: {
loadFromURL: async () => content,
},
});
const { parseChangelog, parseIndex } = await import('../markdown.mjs');
describe('parseChangelog', () => {
it('should parse Node.js versions and their LTS status', async () => {
content = dedent`
* [Node.js 24](doc/changelogs/CHANGELOG_V24.md) **Current**
* [Node.js 22](doc/changelogs/CHANGELOG_V22.md) **Long Term Support**\n
`;
const results = await parseChangelog('...');
assert.partialDeepStrictEqual(results, [
{ version: { raw: '24.0.0' }, isLts: false },
{ version: { raw: '22.0.0' }, isLts: true },
]);
});
});
describe('parseIndex', () => {
it('should retrieve document titles for sidebar generation', async () => {
content = dedent`
# API Documentation
* [Assert](assert.md)
* [Buffer](buffer.md)
* [Child Process](child_process.md)
* [Something](not-a-markdown-file)
`;
const results = await parseIndex('...');
assert.deepStrictEqual(results, [
{ section: 'Assert', api: 'assert' },
{ section: 'Buffer', api: 'buffer' },
{ section: 'Child Process', api: 'child_process' },
]);
});
});