From edd7736f75c2d5a3b3f4aa68cb42c2f89daaf5ad Mon Sep 17 00:00:00 2001 From: larte Date: Sat, 4 Mar 2023 09:57:22 +0200 Subject: [PATCH] fix: warmup guard on multiple non warming events --- index.js | 2 +- test/non-warming-events.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5f2aeb5..b7f0185 100644 --- a/index.js +++ b/index.js @@ -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 { diff --git a/test/non-warming-events.js b/test/non-warming-events.js index 7890b59..43f53b0 100644 --- a/test/non-warming-events.js +++ b/test/non-warming-events.js @@ -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() + }) + }) }) })