8
8
import {
9
9
InvalidPathException ,
10
10
Path ,
11
+ PathFragment ,
11
12
asWindowsPath ,
12
13
basename ,
13
14
dirname ,
@@ -83,7 +84,7 @@ describe('path', () => {
83
84
} ) ;
84
85
85
86
describe ( 'split' , ( ) => {
86
- const tests = [
87
+ const tests : [ string , string [ ] ] [ ] = [
87
88
[ 'a' , [ 'a' ] ] ,
88
89
[ '/a/b' , [ '' , 'a' , 'b' ] ] ,
89
90
[ 'a/b' , [ 'a' , 'b' ] ] ,
@@ -92,31 +93,29 @@ describe('path', () => {
92
93
[ '/' , [ '' ] ] ,
93
94
] ;
94
95
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 ) ;
98
98
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 [ ] ) ;
101
101
} ) ;
102
102
}
103
103
} ) ;
104
104
105
105
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' ] ,
112
112
] ;
113
113
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 [ ] ] ;
117
116
118
117
it ( `(${ JSON . stringify ( args ) } ) == "${ result } "` , ( ) => {
119
- expect ( join . apply ( null , args ) ) . toBe ( result ) ;
118
+ expect ( join ( ... args ) ) . toBe ( result ) ;
120
119
} ) ;
121
120
}
122
121
} ) ;
0 commit comments