1- 'use strict' ;
2-
31import assert from 'node:assert/strict' ;
42import { describe , it } from 'node:test' ;
53
@@ -11,10 +9,10 @@ const {
119} = await import ( '../index.mjs' ) ;
1210
1311const pages = [
14- [ 'File System API' , 'fs' , 'File System' ] ,
15- [ 'HTTP API' , 'http' , 'Networking' ] ,
16- [ 'Path API' , 'path' , 'File System' ] ,
17- [ 'Index' , 'index' ] ,
12+ [ 1 , { heading : 'File System API' , path : 'fs' , category : 'File System' } ] ,
13+ [ 2 , { heading : 'HTTP API' , path : 'http' , category : 'Networking' } ] ,
14+ [ 3 , { heading : 'Path API' , path : 'path' , category : 'File System' } ] ,
15+ [ - 1 , { heading : 'Index' , path : 'index' } ] ,
1816] ;
1917
2018const versions = [
@@ -46,9 +44,9 @@ describe('buildSideBarGroups', () => {
4644
4745 it ( 'puts entries without category into an Others group at the end by default' , ( ) => {
4846 const uncategorizedPages = [
49- [ 'Buffer' , 'buffer' , 'Binary' ] ,
50- [ 'Unknown' , 'unknown' ] ,
51- [ 'Config' , 'config' , '' ] ,
47+ [ 1 , { heading : 'Buffer' , path : 'buffer' , category : 'Binary' } ] ,
48+ [ - 1 , { heading : 'Unknown' , path : 'unknown' } ] ,
49+ [ - 1 , { heading : 'Config' , path : 'config' , category : '' } ] ,
5250 ] ;
5351 const metadata = { path : 'buffer' , basename : 'buffer' } ;
5452
@@ -64,7 +62,7 @@ describe('buildSideBarGroups', () => {
6462 it ( 'uses a custom default group name when provided' , ( ) => {
6563 const metadata = { path : 'unknown' , basename : 'unknown' } ;
6664 const result = buildSideBarGroups (
67- [ [ 'Unknown' , 'unknown' ] ] ,
65+ [ [ - 1 , { heading : 'Unknown' , path : 'unknown' } ] ] ,
6866 metadata ,
6967 'General'
7068 ) ;
@@ -113,9 +111,59 @@ describe('getSidebarItems', () => {
113111 const metadata = { path : 'guide/fs' , basename : 'fs' } ;
114112 const result = getSidebarItems (
115113 [
116- [ 'File System API' , 'guide/fs' , 'File System' ] ,
117- [ 'HTTP API' , 'guide/http' , 'Networking' ] ,
118- [ 'Child API' , 'guide/sub/child' ] ,
114+ [
115+ 1 ,
116+ {
117+ heading : 'File System API' ,
118+ path : 'guide/fs' ,
119+ category : 'File System' ,
120+ } ,
121+ ] ,
122+ [
123+ 2 ,
124+ { heading : 'HTTP API' , path : 'guide/http' , category : 'Networking' } ,
125+ ] ,
126+ [ - 1 , { heading : 'Child API' , path : 'guide/sub/child' } ] ,
127+ ] ,
128+ metadata
129+ ) ;
130+
131+ assert . deepStrictEqual ( result , [
132+ {
133+ label : 'File System API' ,
134+ link : 'fs.html' ,
135+ category : 'File System' ,
136+ } ,
137+ {
138+ label : 'HTTP API' ,
139+ link : 'http.html' ,
140+ category : 'Networking' ,
141+ } ,
142+ {
143+ label : 'Child API' ,
144+ link : 'sub/child.html' ,
145+ category : undefined ,
146+ } ,
147+ ] ) ;
148+ } ) ;
149+
150+ it ( 'maps the new [weight, page] tuple shape' , ( ) => {
151+ const metadata = { path : 'guide/fs' , basename : 'fs' } ;
152+ const result = getSidebarItems (
153+ [
154+ [
155+ 10 ,
156+ {
157+ heading : 'File System API' ,
158+ path : 'guide/fs' ,
159+ category : 'File System' ,
160+ } ,
161+ ] ,
162+ [
163+ 20 ,
164+ { heading : 'HTTP API' , path : 'guide/http' , category : 'Networking' } ,
165+ ] ,
166+ [ - 1 , { heading : 'Child API' , path : 'guide/sub/child' } ] ,
119167 ] ,
120168 metadata
121169 ) ;
0 commit comments