Skip to content

Commit e5975d0

Browse files
Undo accidental changes
1 parent bcfe1c2 commit e5975d0

File tree

2 files changed

+53
-23
lines changed

2 files changed

+53
-23
lines changed

test/integration/change-streams/change_stream.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { gte, lt } from 'semver';
55
import * as sinon from 'sinon';
66
import { PassThrough } from 'stream';
77
import { setTimeout } from 'timers';
8-
import { inspect, promisify } from 'util';
8+
import { promisify } from 'util';
99

1010
import {
1111
AbstractCursor,

test/unit/sdam/monitor.test.ts

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -400,41 +400,71 @@ describe('monitoring', function () {
400400
});
401401
});
402402

403-
context('when it has been < minHeartbeatFrequencyMS since fn() last completed', function () {
403+
context(
404+
'when it has been < minHeartbeatFrequencyMS and >= 0 since fn() last completed',
405+
function () {
406+
beforeEach(function () {
407+
executor = new MonitorInterval(fnSpy, {
408+
minHeartbeatFrequencyMS: 10,
409+
heartbeatFrequencyMS: 30
410+
});
411+
412+
// call fn() once
413+
clock.tick(30);
414+
expect(fnSpy.calledOnce).to.be.true;
415+
416+
fnSpy.callCount = 0;
417+
418+
// advance less than minHeartbeatFrequency
419+
clock.tick(5);
420+
421+
executor.wake();
422+
});
423+
424+
it('reschedules fn() to minHeartbeatFrequencyMS after the last call', function () {
425+
expect(fnSpy.callCount).to.equal(0);
426+
clock.tick(5);
427+
expect(fnSpy.calledOnce).to.be.true;
428+
});
429+
430+
context('when wake() is called more than once', function () {
431+
it('schedules fn() minHeartbeatFrequencyMS after the last call to fn()', function () {
432+
executor.wake();
433+
executor.wake();
434+
executor.wake();
435+
436+
expect(fnSpy.callCount).to.equal(0);
437+
clock.tick(5);
438+
expect(fnSpy.calledOnce).to.be.true;
439+
});
440+
});
441+
}
442+
);
443+
444+
context('when it has been <0 since fn() has last executed', function () {
404445
beforeEach(function () {
405446
executor = new MonitorInterval(fnSpy, {
406447
minHeartbeatFrequencyMS: 10,
407448
heartbeatFrequencyMS: 30
408449
});
409450

410-
// call fn() once
411-
clock.tick(30);
412-
expect(fnSpy.calledOnce).to.be.true;
413-
414-
fnSpy.callCount = 0;
415-
416-
// advance less than minHeartbeatFrequency
417-
clock.tick(5);
418-
451+
// negative ticks aren't supported, so manually set execution time
452+
executor.lastExecutionEnded = Infinity;
419453
executor.wake();
420454
});
421455

422-
it('reschedules fn() to minHeartbeatFrequencyMS after the last call', function () {
423-
expect(fnSpy.callCount).to.equal(0);
424-
clock.tick(5);
456+
it('executes fn() immediately', function () {
425457
expect(fnSpy.calledOnce).to.be.true;
426458
});
427459

428-
context('when wake() is called more than once', function () {
429-
it('schedules fn() minHeartbeatFrequencyMS after the last call to fn()', function () {
430-
executor.wake();
431-
executor.wake();
432-
executor.wake();
460+
it('reschedules fn() to minHeartbeatFrequency away', function () {
461+
fnSpy.callCount = 0;
433462

434-
expect(fnSpy.callCount).to.equal(0);
435-
clock.tick(5);
436-
expect(fnSpy.calledOnce).to.be.true;
437-
});
463+
clock.tick(29);
464+
expect(fnSpy.callCount).to.equal(0);
465+
466+
clock.tick(1);
467+
expect(fnSpy.calledOnce).to.be.true;
438468
});
439469
});
440470
});

0 commit comments

Comments
 (0)