Skip to content

Commit

Permalink
Merge pull request #697 from ljharb/package_tests
Browse files Browse the repository at this point in the history
[Tests] make package tests more robust by only checking .js files
  • Loading branch information
ljharb committed Dec 22, 2016
2 parents 3781aff + 5d94569 commit c975742
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/src/package.js
Expand Up @@ -3,6 +3,10 @@ var expect = require('chai').expect
var path = require('path')
, fs = require('fs')

function isJSFile(f) {
return path.extname(f) === '.js'
}

describe('package', function () {
let pkg = path.join(process.cwd(), 'src')
, module
Expand All @@ -22,7 +26,7 @@ describe('package', function () {
, function (err, files) {
expect(err).not.to.exist

files.forEach(function (f) {
files.filter(isJSFile).forEach(function (f) {
expect(module.rules).to.have
.property(path.basename(f, '.js'))
})
Expand All @@ -34,9 +38,9 @@ describe('package', function () {
it('exports all configs', function (done) {
fs.readdir(path.join(process.cwd(), 'config'), function (err, files) {
if (err) { done(err); return }
files.forEach(file => {
files.filter(isJSFile).forEach(file => {
if (file[0] === '.') return
expect(module.configs).to.have.property(file.slice(0, -3)) // drop '.js'
expect(module.configs).to.have.property(path.basename(file, '.js'))
})
done()
})
Expand Down

0 comments on commit c975742

Please sign in to comment.