@@ -8,7 +8,7 @@ import { unlink } from 'fs/promises';
88import { describe , it , expect , vi , beforeEach } from 'vitest' ;
99
1010import { bundleFile } from './bundle.ts' ;
11- import { watchDir , makeWatchEvents , filterOnlyJsFiles } from './watch.ts' ;
11+ import { watchDir , makeWatchEvents , shouldIgnore } from './watch.ts' ;
1212
1313vi . mock ( 'fs/promises' , ( ) => ( {
1414 unlink : vi . fn ( async ( ) => new Promise < void > ( ( ) => undefined ) ) ,
@@ -46,21 +46,22 @@ describe('watchDir', () => {
4646 } ) ;
4747} ) ;
4848
49- describe ( 'filterOnlyJsFiles ' , ( ) => {
49+ describe ( 'shouldIgnore ' , ( ) => {
5050 const missingStats = undefined as unknown as Stats ;
5151 const fileStats = { isFile : ( ) => true } as unknown as Stats ;
5252 const nonFileStats = { isFile : ( ) => false } as unknown as Stats ;
5353
5454 it . each `
55- description | file | stats | expectation
56- ${ 'a file with missing stats' } | ${ 'test.js' } | ${ missingStats } | ${ false }
57- ${ 'a non-file' } | ${ 'test.js' } | ${ nonFileStats } | ${ false }
58- ${ 'a .ts file' } | ${ 'test.ts' } | ${ fileStats } | ${ false }
59- ${ 'a .bundle file' } | ${ 'test.bundle' } | ${ fileStats } | ${ false }
60- ${ 'a .txt file' } | ${ 'test.txt' } | ${ nonFileStats } | ${ false }
61- ${ 'a .js file' } | ${ 'test.js' } | ${ fileStats } | ${ true }
55+ description | file | stats | expectation
56+ ${ 'a file with missing stats' } | ${ 'test.js' } | ${ missingStats } | ${ false }
57+ ${ 'a non-file' } | ${ 'test.js' } | ${ nonFileStats } | ${ false }
58+ ${ 'a .js file' } | ${ 'test.js' } | ${ fileStats } | ${ false }
59+ ${ 'a .ts file' } | ${ 'test.ts' } | ${ fileStats } | ${ true }
60+ ${ 'a .bundle file' } | ${ 'test.bundle' } | ${ fileStats } | ${ true }
61+ ${ 'a .txt file' } | ${ 'test.txt' } | ${ fileStats } | ${ true }
62+ ${ 'a .js file in node_modules' } | ${ 'node_modules/test.js' } | ${ fileStats } | ${ true }
6263 ` ( 'returns $expectation for $description' , ( { file, expectation, stats } ) => {
63- expect ( filterOnlyJsFiles ( file , stats ) ) . toBe ( expectation ) ;
64+ expect ( shouldIgnore ( file , stats ) ) . toBe ( expectation ) ;
6465 } ) ;
6566} ) ;
6667
0 commit comments