Skip to content

Commit

Permalink
fix: warmup guard on multiple non warming events
Browse files Browse the repository at this point in the history
  • Loading branch information
larte committed Mar 4, 2023
1 parent 60f2fa2 commit edd7736
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = (event, cfg = {}) => {
if (i < event.length) {
return handleEvent(event[i++], config).then(handleNext)
}
return Promise.resolve(true)
return Promise.resolve(event.some((e) => e[config.flag]))
}
return handleNext()
} else {
Expand Down
17 changes: 17 additions & 0 deletions test/non-warming-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ describe('Non-warming Event Tests', function() {
done()
})
})

it('should return false for list of non warmer events', function(done) {
this.slow(500)
let warmer = rewire('../index')
let event = [{ foo:'bar' }, { foo: 'baz'}]

let logger = console.log
let logData = {}
console.log = (log) => { logData = log }

warmer(event, { log:false }).then(out => {
console.log = logger // restore console.log
expect(logData).to.deep.equal({})
expect(out).to.equal(false)
done()
})
})
})

})

0 comments on commit edd7736

Please sign in to comment.