Skip to content

Commit

Permalink
fix(tick): only tick once for mockWebsocket
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisadubois committed Nov 19, 2024
1 parent abf5283 commit e852931
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ describe('plugin-mercury', () => {

describe('when webSocketUrl is provided', () => {
it('connects to Mercury with provided url', () => {
const clientTimestamp = Date.now();
sinon.useFakeTimers(clientTimestamp);
const webSocketUrl = 'ws://providedurl.com';
const promise = mercury.connect(webSocketUrl);

Expand All @@ -448,7 +450,7 @@ describe('plugin-mercury', () => {
assert.calledWith(
Socket.prototype.open,
sinon.match(/ws:\/\/providedurl.com/),
sinon.match.has('clientTimestamp', clock.now + 2) // 2 for 2 ticks
sinon.match.has('clientTimestamp', clientTimestamp + 1) // process.nextTick(() => mockWebSocket.open()); the mock websocket has a clock.tick of 1
);
});
});
Expand Down

0 comments on commit e852931

Please sign in to comment.