Skip to content

Commit

Permalink
add relevant api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Mar 5, 2017
1 parent 7c7f89f commit 297027a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/api.js
Expand Up @@ -149,3 +149,25 @@ test('.lintFiles() - only accepts whitelisted extensions', async t => {
const moreExtensionsResults = await fn.lintFiles(mdGlob, {extensions: ['md']});
t.true(moreExtensionsResults.errorCount > 0);
});

test('.lintFiles() - ignores dirs for empty extensions', async t => {
{
const glob = path.join(__dirname, 'fixtures/nodir/*');
const results = await fn.lintFiles(glob, {extensions: ['', 'js']});
const {results: [fileResult]} = results;

// only fixtures/nodir/noextension should be linted
t.is(path.relative(__dirname, fileResult.filePath), 'fixtures/nodir/noextension');
t.is(results.errorCount, 1);
}

{
const glob = path.join(__dirname, 'fixtures/nodir/nested/*');
const results = await fn.lintFiles(glob);
const {results: [fileResult]} = results;

// ensure nodir/nested **would** report if globbed
t.is(path.relative(__dirname, fileResult.filePath), 'fixtures/nodir/nested/index.js');
t.is(results.errorCount, 1);
}
});
1 change: 1 addition & 0 deletions test/fixtures/nodir/nested/index.js
@@ -0,0 +1 @@
console.log("should not report");
1 change: 1 addition & 0 deletions test/fixtures/nodir/noextension
@@ -0,0 +1 @@
console.log("should report");

0 comments on commit 297027a

Please sign in to comment.