@@ -8,8 +8,12 @@ describe('script name comparator', () => {
88 const A_BEFORE_B = - 1 ;
99 const baseScriptName = any . word ( ) ;
1010
11- it ( 'should consider undefined sort orders as equivalent' , async ( ) => {
12- expect ( compareScriptNames ( any . word ( ) , any . word ( ) ) ) . toEqual ( 0 ) ;
11+ it ( 'should sort alphabetically if no other rules apply' , async ( ) => {
12+ const a = `a${ any . word ( ) } ` ;
13+ const b = `b${ any . word ( ) } ` ;
14+
15+ expect ( compareScriptNames ( a , b ) ) . toEqual ( A_BEFORE_B ) ;
16+ expect ( compareScriptNames ( b , a ) ) . toEqual ( A_AFTER_B ) ;
1317 } ) ;
1418
1519 it ( 'should sort `pre` scripts ahead of their related scripts' , async ( ) => {
@@ -47,6 +51,17 @@ describe('script name comparator', () => {
4751 expect ( compareScriptNames ( `pretest:${ any . word ( ) } ` , `prelint:${ any . word ( ) } ` ) ) . toEqual ( A_AFTER_B ) ;
4852 } ) ;
4953
54+ it ( 'should sort subscripts alphabetically' , async ( ) => {
55+ const a = `a${ any . word ( ) } ` ;
56+ const b = `b${ any . word ( ) } ` ;
57+
58+ expect ( compareScriptNames ( `lint:${ a } ` , `lint:${ b } ` ) ) . toEqual ( A_BEFORE_B ) ;
59+ expect ( compareScriptNames ( `lint:${ b } ` , `lint:${ a } ` ) ) . toEqual ( A_AFTER_B ) ;
60+
61+ expect ( compareScriptNames ( `test:${ a } ` , `test:${ b } ` ) ) . toEqual ( A_BEFORE_B ) ;
62+ expect ( compareScriptNames ( `test:${ b } ` , `test:${ a } ` ) ) . toEqual ( A_AFTER_B ) ;
63+ } ) ;
64+
5065 it ( 'should sort undefined scripts below `lint:` scripts' , async ( ) => {
5166 expect ( compareScriptNames ( any . word ( ) , `lint:${ any . word ( ) } ` ) ) . toEqual ( A_AFTER_B ) ;
5267 expect ( compareScriptNames ( `lint:${ any . word ( ) } ` , any . word ( ) ) ) . toEqual ( A_BEFORE_B ) ;
0 commit comments