File tree 3 files changed +58
-3
lines changed
3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -107,3 +107,29 @@ Array [
107
107
} ,
108
108
]
109
109
` ;
110
+
111
+ exports [` sort toc with files absolute path 2` ] = `
112
+ Array [
113
+ Object {
114
+ " context" : Object {
115
+ " sortKey" : " a" ,
116
+ },
117
+ " memberof" : " classB" ,
118
+ " name" : " apples" ,
119
+ } ,
120
+ Object {
121
+ " context" : Object {
122
+ " sortKey" : " c" ,
123
+ },
124
+ " memberof" : " classB" ,
125
+ " name" : " bananas" ,
126
+ } ,
127
+ Object {
128
+ " context" : Object {
129
+ " sortKey" : " b" ,
130
+ },
131
+ " memberof" : " classB" ,
132
+ " name" : " carrot" ,
133
+ } ,
134
+ ]
135
+ ` ;
Original file line number Diff line number Diff line change 1
- var sort = require ( '../../src/sort' ) , path = require ( 'path' ) ;
1
+ var sort = require ( '../../src/sort' ) ,
2
+ path = require ( 'path' ) ;
2
3
3
4
test ( 'sort stream alphanumeric' , function ( ) {
4
5
var apples = { context : { sortKey : 'a' } , name : 'apples' } ;
@@ -204,3 +205,31 @@ test('sort toc with files absolute path', function() {
204
205
} )
205
206
) . toMatchSnapshot ( ) ;
206
207
} ) ;
208
+
209
+ test ( 'sort toc with files absolute path' , function ( ) {
210
+ var apples = {
211
+ context : { sortKey : 'a' } ,
212
+ name : 'apples' ,
213
+ memberof : 'classB'
214
+ } ;
215
+ var carrot = {
216
+ context : { sortKey : 'b' } ,
217
+ name : 'carrot' ,
218
+ memberof : 'classB'
219
+ } ;
220
+ var bananas = {
221
+ context : { sortKey : 'c' } ,
222
+ name : 'bananas' ,
223
+ memberof : 'classB'
224
+ } ;
225
+
226
+ var snowflake = {
227
+ name : 'snowflake' ,
228
+ file : path . join ( __dirname , '../fixture/snowflake.md' )
229
+ } ;
230
+ expect (
231
+ sort ( [ carrot , apples , bananas ] , {
232
+ sortOrder : 'alpha'
233
+ } )
234
+ ) . toMatchSnapshot ( ) ;
235
+ } ) ;
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ function compare(a: string, b: string) {
99
99
}
100
100
101
101
function compareCommentsByName ( a , b ) {
102
- var akey = a . memberof || a . name ;
103
- var bkey = b . memberof || b . name ;
102
+ var akey = a . name ;
103
+ var bkey = b . name ;
104
104
105
105
if ( akey && bkey ) {
106
106
return compare ( akey , bkey ) ;
You can’t perform that action at this time.
0 commit comments