-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathbuildBarProps.test.mjs
More file actions
31 lines (26 loc) · 1.15 KB
/
buildBarProps.test.mjs
File metadata and controls
31 lines (26 loc) · 1.15 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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { SAMPLE } from './utils.mjs';
import { buildSideBarDocPages, buildMetaBarProps } from '../buildBarProps.mjs';
describe('buildBarProps utilities', () => {
describe('buildSideBarDocPages', () => {
it('should return expected format', () => {
const grouped = new Map([['sample-api', [SAMPLE]]]);
const result = buildSideBarDocPages(grouped, [SAMPLE]);
assert.equal(result.length, 1);
assert.equal(result[0].title, 'SampleFunc');
assert.equal(result[0].doc, 'sample-api.html');
assert.deepEqual(result[0].headings, [['SampleFunc', '#sample-func']]);
});
});
describe('buildMetaBarProps', () => {
it('should include expected fields', () => {
const result = buildMetaBarProps(SAMPLE, [SAMPLE]);
assert.equal(result.addedIn, 'v1.0.0');
assert.deepEqual(result.viewAs, [['JSON', 'sample-api.json']]);
assert.ok(result.readingTime.startsWith('1 min'));
assert.ok(result.editThisPage.endsWith('sample-api.md'));
assert.deepEqual(result.headings, [{ depth: 2, value: 'SampleFunc' }]);
});
});
});