Skip to content

Commit

Permalink
test: fix t.end() error in tests for tape 5
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Oct 29, 2020
1 parent f4d0b4b commit 1815aa9
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,7 @@ var deglob = require('../')
var playground = path.join(__dirname, 'playground')
var opts = { cwd: playground, gitIgnoreFile: 'custom-gitignore' }

test('all of the things', function (t) {
globbies.forEach(function (obj) {
deglob(obj.globs, obj.opts, checkEm)

function checkEm (err, files) {
if (err) throw err
var testName = obj.name + ' -- matches ' + obj.expectedFiles.length + ' files'
t.equals(files.length, obj.expectedFiles.length, testName)
obj.expectedFiles.forEach(function (expectedFile) {
t.ok(files.indexOf(path.join(playground, expectedFile)) > -1, 'File in Result: ' + expectedFile)
})
}
})

t.end()
})

var globbies = [
const globbies = [
{
name: '*.txt useGitIgnore: default, usePackageJson: default',
globs: '*.txt',
Expand Down Expand Up @@ -62,3 +45,19 @@ var globbies = [
expectedFiles: ['ignored-by-package-json.txt']
}
]

globbies.forEach(function (obj) {
test('Testing ' + obj.name, function (t) {
deglob(obj.globs, obj.opts, checkEm)

function checkEm (err, files) {
if (err) throw err
var testName = obj.name + ' -- matches ' + obj.expectedFiles.length + ' files'
t.equals(files.length, obj.expectedFiles.length, testName)
obj.expectedFiles.forEach(function (expectedFile) {
t.ok(files.indexOf(path.join(playground, expectedFile)) > -1, 'File in Result: ' + expectedFile)
})
t.end()
}
})
})

0 comments on commit 1815aa9

Please sign in to comment.