88import {
99 InvalidPathException ,
1010 Path ,
11+ PathFragment ,
1112 asWindowsPath ,
1213 basename ,
1314 dirname ,
@@ -83,7 +84,7 @@ describe('path', () => {
8384 } ) ;
8485
8586 describe ( 'split' , ( ) => {
86- const tests = [
87+ const tests : [ string , string [ ] ] [ ] = [
8788 [ 'a' , [ 'a' ] ] ,
8889 [ '/a/b' , [ '' , 'a' , 'b' ] ] ,
8990 [ 'a/b' , [ 'a' , 'b' ] ] ,
@@ -92,31 +93,29 @@ describe('path', () => {
9293 [ '/' , [ '' ] ] ,
9394 ] ;
9495
95- for ( const goldens of tests ) {
96- const result = goldens . pop ( ) ;
97- const args = goldens . map ( ( x : string ) => normalize ( x ) ) as Path [ ] ;
96+ for ( const [ input , result ] of tests ) {
97+ const normalizedInput = normalize ( input ) ;
9898
99- it ( `(${ JSON . stringify ( args ) } ) == "${ result } "` , ( ) => {
100- expect ( split . apply ( null , args ) ) . toEqual ( result ) ;
99+ it ( `(${ JSON . stringify ( normalizedInput ) } ) == "${ result } "` , ( ) => {
100+ expect ( split ( normalizedInput ) ) . toEqual ( result as PathFragment [ ] ) ;
101101 } ) ;
102102 }
103103 } ) ;
104104
105105 describe ( 'join' , ( ) => {
106- const tests = [
107- [ 'a' , 'a' ] ,
108- [ '/a' , '/b' , '/a/b' ] ,
109- [ '/a' , '/b' , '/c' , '/a/b/c' ] ,
110- [ '/a' , 'b' , 'c' , '/a/b/c' ] ,
111- [ 'a' , 'b' , 'c' , 'a/b/c' ] ,
106+ const tests : [ string [ ] , string ] [ ] = [
107+ [ [ 'a' ] , 'a' ] ,
108+ [ [ '/a' , '/b' ] , '/a/b' ] ,
109+ [ [ '/a' , '/b' , '/c' ] , '/a/b/c' ] ,
110+ [ [ '/a' , 'b' , 'c' ] , '/a/b/c' ] ,
111+ [ [ 'a' , 'b' , 'c' ] , 'a/b/c' ] ,
112112 ] ;
113113
114- for ( const goldens of tests ) {
115- const result = goldens . pop ( ) ;
116- const args = goldens . map ( x => normalize ( x ) ) as Path [ ] ;
114+ for ( const [ input , result ] of tests ) {
115+ const args = input . map ( x => normalize ( x ) ) as [ Path , ...Path [ ] ] ;
117116
118117 it ( `(${ JSON . stringify ( args ) } ) == "${ result } "` , ( ) => {
119- expect ( join . apply ( null , args ) ) . toBe ( result ) ;
118+ expect ( join ( ... args ) ) . toBe ( result ) ;
120119 } ) ;
121120 }
122121 } ) ;
0 commit comments