diff --git a/src/generators/jsx-ast/utils/synthetic/__tests__/index.test.mjs b/src/generators/jsx-ast/utils/synthetic/__tests__/index.test.mjs index 8d9fc494..f083e905 100644 --- a/src/generators/jsx-ast/utils/synthetic/__tests__/index.test.mjs +++ b/src/generators/jsx-ast/utils/synthetic/__tests__/index.test.mjs @@ -30,6 +30,22 @@ describe('buildIndexPage', () => { assert.equal(head.heading.data.name, 'Index'); assert.equal(head.synthetic, true); }); + + it('sorts the stability overview rows alphabetically by API name', () => { + const { entries } = buildIndexPage([ + fakeHead('fs', 'fs', 2), + fakeHead('assert', 'assert', 2), + fakeHead('crypto', 'crypto', 2), + ]); + + const table = findChild(entries[0].content, 'table'); + const rows = findChild(table, 'tbody').children; + const names = rows.map( + row => row.children[0].children[0].children[0].value + ); + + assert.deepEqual(names, ['assert', 'crypto', 'fs']); + }); }); describe('buildStabilityOverview', () => { diff --git a/src/generators/jsx-ast/utils/synthetic/index.mjs b/src/generators/jsx-ast/utils/synthetic/index.mjs index fbe9ccf2..423d11a0 100644 --- a/src/generators/jsx-ast/utils/synthetic/index.mjs +++ b/src/generators/jsx-ast/utils/synthetic/index.mjs @@ -5,6 +5,7 @@ import { h as createElement } from 'hastscript'; import { createSyntheticHead, wrapAsEntry } from './synthetic.mjs'; import { JSX_IMPORTS } from '../../../web/constants.mjs'; import { createJSXElement } from '../ast.mjs'; +import { getSortedHeadNodes } from '../getSortedHeadNodes.mjs'; const STABILITY_BADGE_KINDS = [ 'error', @@ -67,7 +68,7 @@ export const buildStabilityOverview = headEntries => */ export const buildIndexPage = entries => { const head = createSyntheticHead('index', 'Index'); - const moduleEntries = entries.filter(entry => entry.heading.depth === 1); + const moduleEntries = getSortedHeadNodes(entries); return { head,