Skip to content

Commit 9f59bfb

Browse files
committed
fix(jsx-ast): alpha-sort stability overview
1 parent c04329e commit 9f59bfb

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/generators/jsx-ast/utils/synthetic/__tests__/index.test.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ describe('buildIndexPage', () => {
3030
assert.equal(head.heading.data.name, 'Index');
3131
assert.equal(head.synthetic, true);
3232
});
33+
34+
it('sorts the stability overview rows alphabetically by API name', () => {
35+
const { entries } = buildIndexPage([
36+
fakeHead('fs', 'fs', 2),
37+
fakeHead('assert', 'assert', 2),
38+
fakeHead('crypto', 'crypto', 2),
39+
]);
40+
41+
const table = findChild(entries[0].content, 'table');
42+
const rows = findChild(table, 'tbody').children;
43+
const names = rows.map(
44+
row => row.children[0].children[0].children[0].value
45+
);
46+
47+
assert.deepEqual(names, ['assert', 'crypto', 'fs']);
48+
});
3349
});
3450

3551
describe('buildStabilityOverview', () => {

src/generators/jsx-ast/utils/synthetic/index.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { h as createElement } from 'hastscript';
55
import { createSyntheticHead, wrapAsEntry } from './synthetic.mjs';
66
import { JSX_IMPORTS } from '../../../web/constants.mjs';
77
import { createJSXElement } from '../ast.mjs';
8+
import { getSortedHeadNodes } from '../getSortedHeadNodes.mjs';
89

910
const STABILITY_BADGE_KINDS = [
1011
'error',
@@ -67,7 +68,7 @@ export const buildStabilityOverview = headEntries =>
6768
*/
6869
export const buildIndexPage = entries => {
6970
const head = createSyntheticHead('index', 'Index');
70-
const moduleEntries = entries.filter(entry => entry.heading.depth === 1);
71+
const moduleEntries = getSortedHeadNodes(entries);
7172

7273
return {
7374
head,

0 commit comments

Comments
 (0)