Skip to content

Commit

Permalink
[Tests] make package tests more robust by only checking .js files
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 21, 2016
1 parent e26e898 commit 5d94569
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/src/package.js
Original file line number Diff line number Diff line change
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 5d94569

Please sign in to comment.