From 1d618faaa6d084e85466d5cc0c2b6f9a05213995 Mon Sep 17 00:00:00 2001 From: Jannis Redmann Date: Mon, 16 Jan 2017 10:48:20 +0100 Subject: [PATCH] fix subscribeToEvents test (#4166) * try to fix freaking test * fix subscribeToEvents test This fix is a workaround. I would have used sinon fake timers, but I couldn't get them to work. * subscribeToEvent test: simplify code --- js/src/util/subscribe-to-events.spec.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/js/src/util/subscribe-to-events.spec.js b/js/src/util/subscribe-to-events.spec.js index bbb0d280d..a14d2b36e 100644 --- a/js/src/util/subscribe-to-events.spec.js +++ b/js/src/util/subscribe-to-events.spec.js @@ -95,21 +95,20 @@ describe('util/subscribe-to-events', () => { expect(api.eth.uninstallFilter.firstCall.args).to.eql([ 123 ]); }); - it.skip('checks for new events regularly', async function () { + it('checks for new events regularly', async function () { const { api, contract } = this; api.eth.getFilterLogs = stub().resolves([]); const onLog = spy(); const onBar = spy(); - const s = subscribeToEvents(contract, [ 'Bar' ], { interval: 5 }) + subscribeToEvents(contract, [ 'Bar' ], { interval: 5 }) .on('log', onLog) .on('Bar', onBar); - await delay(9); - s.unsubscribe(); + await delay(10); - expect(onLog.callCount).to.equal(1); + expect(onLog.callCount).to.be.at.least(1); expect(onLog.firstCall.args).to.eql([ liveLogs[0] ]); - expect(onBar.callCount).to.equal(1); + expect(onBar.callCount).to.be.at.least(1); expect(onBar.firstCall.args).to.eql([ liveLogs[0] ]); }); });