@@ -22,3 +22,89 @@ test('sort stream alphanumeric', function (t) {
2222
2323 t . end ( ) ;
2424} ) ;
25+
26+ test ( 'sort stream with configuration' , function ( t ) {
27+ var apples = { context : { sortKey : 'a' } , name : 'apples' } ;
28+ var carrot = { context : { sortKey : 'b' } , name : 'carrot' } ;
29+ var bananas = { context : { sortKey : 'c' } , name : 'bananas' } ;
30+
31+ t . deepEqual ( sort ( [
32+ apples , carrot , bananas
33+ ] , {
34+ toc : [ 'carrot' , 'bananas' ]
35+ } ) , [
36+ carrot , bananas , apples
37+ ] , 'with configuration' ) ;
38+
39+ t . end ( ) ;
40+ } ) ;
41+
42+ test ( 'sort stream with configuration and a section' , function ( t ) {
43+ var apples = { context : { sortKey : 'a' } , name : 'apples' } ;
44+ var carrot = { context : { sortKey : 'b' } , name : 'carrot' } ;
45+ var bananas = { context : { sortKey : 'c' } , name : 'bananas' } ;
46+
47+ var section = { name : 'This is the banana type' , description : 'here lies bananas' } ;
48+
49+ var sectionMarkdown = {
50+ 'name' : 'This is the banana type' ,
51+ 'description' : {
52+ 'type' : 'root' ,
53+ 'children' : [ {
54+ 'type' : 'paragraph' ,
55+ 'children' : [ {
56+ 'type' : 'text' ,
57+ 'value' : 'here lies bananas' ,
58+ 'position' : {
59+ 'start' : {
60+ 'line' : 1 ,
61+ 'column' : 1 ,
62+ 'offset' : 0
63+ } ,
64+ 'end' : {
65+ 'line' : 1 ,
66+ 'column' : 18 ,
67+ 'offset' : 17
68+ } ,
69+ 'indent' : [ ]
70+ }
71+ } ] ,
72+ 'position' : {
73+ 'start' : {
74+ 'line' : 1 ,
75+ 'column' : 1 ,
76+ 'offset' : 0
77+ } ,
78+ 'end' : {
79+ 'line' : 1 ,
80+ 'column' : 18 ,
81+ 'offset' : 17
82+ } , 'indent' : [ ]
83+ }
84+ } ] ,
85+ 'position' : {
86+ 'start' : {
87+ 'line' : 1 ,
88+ 'column' : 1 ,
89+ 'offset' : 0
90+ } ,
91+ 'end' : {
92+ 'line' : 1 ,
93+ 'column' : 18 ,
94+ 'offset' : 17
95+ }
96+ }
97+ } ,
98+ 'kind' : 'note'
99+ } ;
100+
101+ t . deepEqual ( sort ( [
102+ apples , carrot , bananas
103+ ] , {
104+ toc : [ 'carrot' , section , 'bananas' ]
105+ } ) , [
106+ carrot , sectionMarkdown , bananas , apples
107+ ] , 'with configuration' ) ;
108+
109+ t . end ( ) ;
110+ } ) ;
0 commit comments