@@ -181,45 +181,45 @@ describe('find', () => {
181
181
} )
182
182
}
183
183
184
- // fifo test
185
- describe ( 'finding FIFOs' , ( ) => {
186
- let allFilesCount , fifosCount , nonFIFOsCount
184
+ describe ( 'file types' , ( ) => {
185
+ let server
186
+ const symLinkPath = fsPath . join ( symLinkDir , 'symLinkA' )
187
+ const fileAPath = fsPath . join ( symLinkDir , 'fileA.txt' )
187
188
188
189
beforeAll ( async ( ) => {
189
190
tryExec ( 'mkfifo ' + fifoPath )
190
191
191
- const allFiles = await find ( { root : fifoDir , sort : 'none' } )
192
- const fifos = await find ( { onlyFIFOs : true , root : fifoDir , sort : 'none' } )
193
- const nonFIFOs = await find ( { noFIFOs : true , root : fifoDir , sort : 'none' } )
192
+ server = net . createServer ( ( c ) => { } )
193
+ server . listen ( socketAPath , ( ) => { } )
194
194
195
- allFilesCount = allFiles . length
196
- fifosCount = fifos . length
197
- nonFIFOsCount = nonFIFOs . length
195
+ await fs . symlink ( fileAPath , symLinkPath )
198
196
} )
199
197
200
198
afterAll ( async ( ) => {
201
199
await fs . rm ( fifoPath )
202
- } )
203
-
204
- test ( 'counts FIFO with all files' , ( ) => expect ( allFilesCount ) . toBe ( 4 ) )
205
200
206
- test ( "'onlyFIFO' counts only FIFO files" , ( ) => expect ( fifosCount ) . toBe ( 1 ) )
201
+ await server . close ( )
207
202
208
- test ( "'noFIFO' skips FIFO files" , ( ) => expect ( nonFIFOsCount ) . toBe ( 3 ) )
209
- } )
203
+ await fs . rm ( symLinkPath )
204
+ } )
210
205
211
- describe ( 'finding sockets' , ( ) => {
212
- let server
206
+ // fifo test
207
+ test ( 'counts FIFO with all files' , async ( ) => {
208
+ const allFiles = await find ( { root : fifoDir , sort : 'none' } )
209
+ expect ( allFiles ) . toHaveLength ( 4 )
210
+ } )
213
211
214
- beforeAll ( ( ) => {
215
- server = net . createServer ( ( c ) => { } )
216
- server . listen ( socketAPath , ( ) => { } )
212
+ test ( "'onlyFIFO' counts only FIFO files" , async ( ) => {
213
+ const fifos = await find ( { onlyFIFOs : true , root : fifoDir , sort : 'none' } )
214
+ expect ( fifos ) . toHaveLength ( 1 )
217
215
} )
218
216
219
- afterAll ( async ( ) => {
220
- await server . close ( )
217
+ test ( "'noFIFO' skips FIFO files" , async ( ) => {
218
+ const nonFIFOs = await find ( { noFIFOs : true , root : fifoDir , sort : 'none' } )
219
+ expect ( nonFIFOs ) . toHaveLength ( 3 )
221
220
} )
222
221
222
+ // socket tests
223
223
test ( 'counts Socket with all files' , async ( ) => {
224
224
const allFiles = await find ( { root : socketDirPath } )
225
225
expect ( allFiles ) . toHaveLength ( 3 ) // the root and two files
@@ -234,35 +234,28 @@ describe('find', () => {
234
234
const noSocketFiles = await find ( { root : socketDirPath , noSockets : true } )
235
235
expect ( noSocketFiles ) . toEqual ( [ socketDirPath , fsPath . join ( socketDirPath , 'fileA.txt' ) ] )
236
236
} )
237
- } )
238
-
239
- // symlink test
240
- describe ( 'finding symlinks' , ( ) => {
241
- const symLinkPath = fsPath . join ( symLinkDir , 'symLinkA' )
242
- const fileAPath = fsPath . join ( symLinkDir , 'fileA.txt' )
243
- let allFilesCount , nonSymLinksCount , symLinksCount
244
-
245
- beforeAll ( async ( ) => {
246
- await fs . symlink ( fileAPath , symLinkPath )
247
237
238
+ // symlink test
239
+ test ( 'counts symbolic links with all files' , async ( ) => {
248
240
const allFiles = await find ( { root : symLinkDir , sort : 'none' } )
249
- const symLinks = await find ( { onlySymbolicLinks : true , root : symLinkDir , sort : 'none' } )
250
- const nonSymLinks = await find ( { noSymbolicLinks : true , root : symLinkDir , sort : 'none' } )
251
-
252
- allFilesCount = allFiles . length
253
- symLinksCount = symLinks . length
254
- nonSymLinksCount = nonSymLinks . length
241
+ expect ( allFiles ) . toHaveLength ( 4 )
255
242
} )
256
243
257
- afterAll ( async ( ) => {
258
- await fs . rm ( symLinkPath )
244
+ test ( "'onlySymbolicLinks' counts only symbolic links" , async ( ) => {
245
+ const symLinks = await find ( { onlySymbolicLinks : true , root : symLinkDir , sort : 'none' } )
246
+ expect ( symLinks ) . toHaveLength ( 1 )
259
247
} )
260
248
261
- test ( 'counts symbolic links with all files' , ( ) => expect ( allFilesCount ) . toBe ( 4 ) )
262
-
263
- test ( "'onlySymbolicLinks' counts only symbolic links" , ( ) => expect ( symLinksCount ) . toBe ( 1 ) )
249
+ test ( "'noSymbolicLinks' skips symbolic link files" , async ( ) => {
250
+ const nonSymLinks = await find ( { noSymbolicLinks : true , root : symLinkDir , sort : 'none' } )
251
+ expect ( nonSymLinks ) . toHaveLength ( 3 )
252
+ } )
264
253
265
- test ( "'noSymbolicLinks' skips symbolic link files" , ( ) => expect ( nonSymLinksCount ) . toBe ( 3 ) )
254
+ // onlySpecials test
255
+ test ( "'onlySpecials' ignores dirs, files, and symlinks" , async ( ) => {
256
+ const onlySpecials = await find ( { root : dirDataPath , excludePaths : [ 'dirA/**' ] , onlySpecials : true } )
257
+ expect ( onlySpecials ) . toEqual ( [ fifoPath , socketAPath ] )
258
+ } )
266
259
} )
267
260
268
261
describe ( 'argument errors' , ( ) => {
0 commit comments