Skip to content

Commit

Permalink
fix(karma): fixes included:false pattern being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
raspo committed Oct 27, 2015
1 parent ef6f05c commit 4444414
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 14 additions & 5 deletions lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,20 @@ Object.defineProperty(List.prototype, 'files', {
return from(self.buckets.get(p.pattern) || []).sort(byPath)
})

var included = this._patterns.filter(function (pattern) {
return pattern.included
})
.map(function (p) {
return from(self.buckets.get(p.pattern) || []).sort(byPath)
// excluded is a map of excluded paths
var excluded = _.reduce(_.flatten(this._patterns.filter(function (pattern) {
return !pattern.included
}).map(function (p) {
return from(self.buckets.get(p.pattern) || [])
})), function (result, file) {
result[file.path] = true
return result
}, {})

var included = this._patterns.map(function (p) {
return from(self.buckets.get(p.pattern)).filter(function (pattern) {
return !excluded[pattern.path]
}).sort(byPath)
})

var uniqFlat = function (list) {
Expand Down
4 changes: 3 additions & 1 deletion test/unit/file-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function findFile (path, files) {

var PATTERN_LIST = {
'/some/*.js': ['/some/a.js', '/some/b.js'],
'/some/a.js': ['/some/a.js'],
'*.txt': ['/c.txt', '/a.txt', '/b.txt'],
'/a.*': ['/a.txt']
}
Expand Down Expand Up @@ -133,15 +134,16 @@ describe('FileList', () => {
it('returns a flat array of included files', () => {
var files = [
new config.Pattern('/a.*', true, false), // included: false
new config.Pattern('/some/a.js', true, false), // included: false
new config.Pattern('/some/*.js') // included: true
]

list = new List(files, [], emitter, preprocess)

return list.refresh().then(() => {
expect(pathsFrom(list.files.included)).not.to.contain('/a.txt')
expect(pathsFrom(list.files.included)).not.to.contain('/some/a.js')
expect(pathsFrom(list.files.included)).to.deep.equal([
'/some/a.js',
'/some/b.js'
])
})
Expand Down

0 comments on commit 4444414

Please sign in to comment.