diff --git a/lib/cli/lookup-files.js b/lib/cli/lookup-files.js index c49204842a..81e9c261e3 100644 --- a/lib/cli/lookup-files.js +++ b/lib/cli/lookup-files.js @@ -45,9 +45,8 @@ function isHiddenOnUnix(pathname) { * hasMatchingExtname('foo.html', ['js', 'css']); // => false */ function hasMatchingExtname(pathname, exts) { - var suffix = path.extname(pathname).slice(1); return exts.some(function(element) { - return suffix === element; + return pathname.endsWith('.' + element); }); } diff --git a/test/integration/file-utils.spec.js b/test/integration/file-utils.spec.js index 9b8f86e79f..3075bbfec9 100644 --- a/test/integration/file-utils.spec.js +++ b/test/integration/file-utils.spec.js @@ -93,6 +93,34 @@ describe('file utils', function() { ).and('to have length', 2); }); + it('should return ".test.js" files', function() { + fs.writeFileSync( + tmpFile('mocha-utils.test.js'), + 'i have a multipart extension' + ); + var res = lookupFiles(tmpDir, ['test.js'], false).map( + path.normalize.bind(path) + ); + expect(res, 'to contain', tmpFile('mocha-utils.test.js')).and( + 'to have length', + 1 + ); + }); + + it('should return not return "*test.js" files', function() { + fs.writeFileSync( + tmpFile('mocha-utils-test.js'), + 'i do not have a multipart extension' + ); + var res = lookupFiles(tmpDir, ['test.js'], false).map( + path.normalize.bind(path) + ); + expect(res, 'not to contain', tmpFile('mocha-utils-test.js')).and( + 'to have length', + 0 + ); + }); + it('should require the extensions parameter when looking up a file', function() { var dirLookup = function() { return lookupFiles(tmpFile('mocha-utils'), undefined, false);