Skip to content

Commit 3a45da3

Browse files
committed
80% patch cov
1 parent 678089c commit 3a45da3

File tree

3 files changed

+728
-7
lines changed

3 files changed

+728
-7
lines changed
Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

4+
import { visit } from 'unist-util-visit';
5+
46
import { SAMPLE } from './utils.mjs';
57
import { JSX_IMPORTS } from '../../../web/constants.mjs';
68
import buildContent from '../buildContent.mjs';
79

10+
const expectedNames = [
11+
JSX_IMPORTS.NavBar.name,
12+
JSX_IMPORTS.Article.name,
13+
JSX_IMPORTS.SideBar.name,
14+
];
15+
816
describe('buildContent', () => {
917
it('should process entries and include JSX wrapper elements', () => {
1018
const tree = buildContent(
1119
[SAMPLE],
1220
SAMPLE,
1321
{},
1422
{
15-
runSync: x => ({
16-
body: [{ expression: x }],
17-
}),
23+
runSync: x => ({ body: [{ expression: x }] }),
1824
}
1925
);
2026

21-
assert.deepStrictEqual(
22-
tree.children.map(child => child.name),
23-
[JSX_IMPORTS.NavBar.name, JSX_IMPORTS.Article.name]
24-
);
27+
const foundNames = [];
28+
visit(tree, node => node.name && foundNames.push(node.name));
29+
30+
expectedNames.forEach(name => {
31+
assert(
32+
foundNames.includes(name),
33+
`Missing "${name}". Found: ${foundNames.join(', ')}`
34+
);
35+
});
36+
2537
assert.equal(tree.data, SAMPLE);
2638
});
2739
});

src/generators/jsx-ast/utils/__tests__/utils.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export const SAMPLE = {
88
type: 'root',
99
children: [
1010
{ type: 'text', value: 'Example text for testing reading time.' },
11+
{
12+
type: 'blockquote',
13+
children: [{ type: 'text', value: 'Stability: 0 - Zero' }],
14+
data: { index: '0' },
15+
},
1116
],
1217
},
1318
added_in: 'v1.0.0',

0 commit comments

Comments
 (0)