Skip to content

Commit 2e4973e

Browse files
committed
[Tests] make package tests more robust by only checking .js files
1 parent e26e898 commit 2e4973e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/src/package.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ var expect = require('chai').expect
33
var path = require('path')
44
, fs = require('fs')
55

6+
function isJSFile(f) {
7+
return path.extname(f) === '.js'
8+
}
9+
610
describe('package', function () {
711
let pkg = path.join(process.cwd(), 'src')
812
, module
@@ -22,7 +26,7 @@ describe('package', function () {
2226
, function (err, files) {
2327
expect(err).not.to.exist
2428

25-
files.forEach(function (f) {
29+
files.filter(isJSFile).forEach(function (f) {
2630
expect(module.rules).to.have
2731
.property(path.basename(f, '.js'))
2832
})
@@ -34,9 +38,9 @@ describe('package', function () {
3438
it('exports all configs', function (done) {
3539
fs.readdir(path.join(process.cwd(), 'config'), function (err, files) {
3640
if (err) { done(err); return }
37-
files.forEach(file => {
41+
files.filter(isJSFile).forEach(file => {
3842
if (file[0] === '.') return
39-
expect(module.configs).to.have.property(file.slice(0, -3)) // drop '.js'
43+
expect(module.configs).to.have.property(path.basename(file, '.js'))
4044
})
4145
done()
4246
})

0 commit comments

Comments
 (0)