@@ -51,41 +51,43 @@ describe("unittests:: canWatch::", () => {
51
51
} ,
52
52
) ;
53
53
54
- baselineCanWatch (
55
- "getDirectoryToWatchFailedLookupLocation" ,
56
- ( ) => `Determines whether to watch given failed lookup location (file that didnt exist) when resolving module.\r\nIt also determines the directory to watch and whether to watch it recursively or not.` ,
57
- ( { paths, longestPathLength } , baseline ) => {
58
- const recursive = "Recursive" ;
59
- const maxLength = longestPathLength + "/node_modules/@types/dir/subdir/somefile.d.ts" . length ;
60
- const maxLengths = [ maxLength , maxLength , recursive . length ] as const ;
61
- baselineCanWatchForRoot ( paths , baseline , baselineForRoot ) ;
62
- function baselineForRoot ( root : string | undefined ) {
63
- pushHeader ( baseline , [ "Location" , "getDirectoryToWatchFailedLookupLocation" , recursive ] , maxLengths ) ;
64
- paths . forEach ( path => {
65
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/dir/somefile.d.ts" ) , root , maxLengths ) ;
66
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/@types/dir/somefile.d.ts" ) , root , maxLengths ) ;
67
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/dir/subdir/somefile.d.ts" ) , root , maxLengths ) ;
68
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/@types/dir/subdir/somefile.d.ts" ) , root , maxLengths ) ;
69
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/somefile.d.ts" ) , root , maxLengths ) ;
70
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "node_modules/@types/somefile.d.ts" ) , root , maxLengths ) ;
71
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "somefile.d.ts" ) , root , maxLengths ) ;
72
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "dir/somefile.d.ts" ) , root , maxLengths ) ;
73
- baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , "dir/subdir/somefile.d.ts" ) , root , maxLengths ) ;
74
- } ) ;
75
- }
76
- function baselineGetDirectoryToWatchFailedLookupLocation ( path : string , root : string | undefined , maxLengths : readonly number [ ] ) {
77
- const result = ts . getDirectoryToWatchFailedLookupLocation (
78
- path ,
79
- path as ts . Path ,
80
- root ,
81
- root as ts . Path | undefined ,
82
- root !== undefined ? root . split ( ts . directorySeparator ) . length : 0 ,
83
- ts . returnUndefined ,
84
- ) ;
85
- pushRow ( baseline , [ path , result ? result . dir : "" , result ? `${ ! result . nonRecursive } ` : "" ] , maxLengths ) ;
86
- }
87
- } ,
88
- ) ;
54
+ baselineGetDirectoryToWatchOfFailedLookup ( "getDirectoryToWatchFailedLookupLocationNodeModules" , "node_modules" ) ;
55
+ baselineGetDirectoryToWatchOfFailedLookup ( "getDirectoryToWatchFailedLookupLocationAtTypes" , "node_modules/@types" ) ;
56
+ baselineGetDirectoryToWatchOfFailedLookup ( "getDirectoryToWatchFailedLookupLocation" , "" ) ;
57
+ function baselineGetDirectoryToWatchOfFailedLookup (
58
+ scenario : string ,
59
+ forPath : "node_modules" | "node_modules/@types" | "" ,
60
+ ) {
61
+ baselineCanWatch (
62
+ scenario ,
63
+ ( ) => `Determines whether to watch given failed lookup location (file that didnt exist) when resolving module.\r\nIt also determines the directory to watch and whether to watch it recursively or not.` ,
64
+ ( { paths, longestPathLength } , baseline ) => {
65
+ const recursive = "Recursive" ;
66
+ const maxLength = longestPathLength + ts . combinePaths ( forPath , "dir/subdir/somefile.d.ts" ) . length ;
67
+ const maxLengths = [ maxLength , maxLength , recursive . length ] as const ;
68
+ baselineCanWatchForRoot ( paths , baseline , baselineForRoot ) ;
69
+ function baselineForRoot ( root : string | undefined ) {
70
+ pushHeader ( baseline , [ "Location" , "getDirectoryToWatchFailedLookupLocation" , recursive ] , maxLengths ) ;
71
+ paths . forEach ( path => {
72
+ baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , forPath , "somefile.d.ts" ) , root , maxLengths ) ;
73
+ baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , forPath , "dir/somefile.d.ts" ) , root , maxLengths ) ;
74
+ baselineGetDirectoryToWatchFailedLookupLocation ( ts . combinePaths ( path , forPath , "dir/subdir/somefile.d.ts" ) , root , maxLengths ) ;
75
+ } ) ;
76
+ }
77
+ function baselineGetDirectoryToWatchFailedLookupLocation ( path : string , root : string | undefined , maxLengths : readonly number [ ] ) {
78
+ const result = ts . getDirectoryToWatchFailedLookupLocation (
79
+ path ,
80
+ path as ts . Path ,
81
+ root ,
82
+ root as ts . Path | undefined ,
83
+ root !== undefined ? root . split ( ts . directorySeparator ) . length : 0 ,
84
+ ts . returnUndefined ,
85
+ ) ;
86
+ pushRow ( baseline , [ path , result ? result . dir : "" , result ? `${ ! result . nonRecursive } ` : "" ] , maxLengths ) ;
87
+ }
88
+ } ,
89
+ ) ;
90
+ }
89
91
90
92
baselineCanWatch (
91
93
"getDirectoryToWatchFailedLookupLocationFromTypeRoot" ,
@@ -124,7 +126,11 @@ describe("unittests:: canWatch::", () => {
124
126
}
125
127
}
126
128
127
- function baselineCanWatch ( scenario : string , info : ( ) => string , baselineOsRoot : ( pathsAtRoot : PathAndLongPathLength , baseline : string [ ] ) => void ) {
129
+ function baselineCanWatch (
130
+ scenario : string ,
131
+ info : ( ) => string ,
132
+ baselineOsRoot : ( pathsAtRoot : PathAndLongPathLength , baseline : string [ ] ) => void ,
133
+ ) {
128
134
it ( `${ scenario } Unix` , ( ) => {
129
135
baselineCanWatchForOsRoot ( scenario , "Unix" , "/" , info , baselineOsRoot ) ;
130
136
} ) ;
0 commit comments