'use strict' ; const assert = require ( 'power-assert' ) ; import * as proxyquire from 'proxyquire' ; const globMock = { } ; const fsMock = { lstatSync : ( file ) : any => ( { isFile : ( ) => ! /\.non-file/ . test ( file ) , isSymbolicLink : ( ) => /.sym/ . test ( file ) , isDirectory : ( ) => file . indexOf ( '.' ) === - 1 } ) } ; import { FileMatcher as ActualFileMatcher } from '../fileMatcher' ; const fileMatcherModule = proxyquire ( '../fileMatcher' , { glob : globMock , fs : fsMock } ) ; const FileMatcher = fileMatcherModule . FileMatcher ; const basePath = '/file-matcher-test/' ; function createSyncMockFunction ( baseMap ) { return ( path ) => { return ( baseMap [ path . substring ( basePath . length ) ] || [ ] ) . map ( ( file ) => `${ basePath }${ file }` ) ; } ; } describe ( 'FileMatcher' , ( ) => { globMock . sync = createSyncMockFunction ( { '**/**' : [ 'index.ts' , 'index.js' , 'some.non-file.ts' , 'some.sym.ts' , 'src' , 'src/lib' , 'src/lib/util.ts' , 'src/lib/util.js' , 'node_modules' , 'node_modules/util/util.ts' , 'node_modules/util/util.js' , 'node_modules/README.md' ] , 'node_modules' : [ 'node_modules' , 'node_modules/util/util.ts' , 'node_modules/util/util.js' , 'node_modules/README.md' ] , '*.ts' : [ 'index.ts' , 'some.non-file.ts' , 'some.sym.ts' , ] , 'src/**/*' : [ 'src/lib' , 'src/lib/util.ts' , 'src/lib/util.js' , ] } ) ; const fileMatcher = new FileMatcher ( basePath , [ '.ts' ] ) ; describe ( '.matchFiles(includePaths: string[])' , ( ) => { it ( 'passes' , ( done ) => { const expected = [ `${ basePath }index.ts` , `${ basePath }src/lib/util.ts` ] ; const actual = fileMatcher . matchFiles ( [ '*.ts' , 'src/**/*' ] ) ; assert . deepStrictEqual ( actual , expected ) ; done ( ) ; } ) ; it ( 'passes with empty list' , ( done ) => { assert . deepStrictEqual ( fileMatcher . matchFiles ( [ ] ) , [ ] ) ; done ( ) ; } ) ; } ) ; } ) ;