From 0dca224d0bbaaec8453b204af2a615e1bb101ccc Mon Sep 17 00:00:00 2001 From: juergba Date: Wed, 15 May 2019 11:22:31 +0200 Subject: [PATCH] tests --- test/integration/file-utils.spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/integration/file-utils.spec.js b/test/integration/file-utils.spec.js index f09018871b..ae97b996e2 100644 --- a/test/integration/file-utils.spec.js +++ b/test/integration/file-utils.spec.js @@ -66,6 +66,34 @@ describe('file utils', function() { expect(res, 'to contain', nonJsFile).and('to have length', 1); }); + it('should return only the ".js" file', function() { + var TsFile = tmpFile('mocha-utils.ts'); + fs.writeFileSync(TsFile, 'yippy skippy ying yang yow'); + + var res = utils + .lookupFiles(tmpFile('mocha-utils'), ['js'], false) + .map(path.normalize.bind(path)); + expect(res, 'to contain', tmpFile('mocha-utils.js')).and( + 'to have length', + 1 + ); + }); + + it('should return ".js" and ".ts" files', function() { + var TsFile = tmpFile('mocha-utils.ts'); + fs.writeFileSync(TsFile, 'yippy skippy ying yang yow'); + + var res = utils + .lookupFiles(tmpFile('mocha-utils'), ['js', 'ts'], false) + .map(path.normalize.bind(path)); + expect( + res, + 'to contain', + tmpFile('mocha-utils.js'), + tmpFile('mocha-utils.ts') + ).and('to have length', 2); + }); + it('should require the extensions parameter when looking up a file', function() { var dirLookup = function() { return utils.lookupFiles(tmpFile('mocha-utils'), undefined, false);