Skip to content

Commit

Permalink
add timeouts to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Dec 22, 2023
1 parent 4f8a615 commit 4e7a507
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/scenarios/subscriptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ export function testSubscriptionScenarios(): void {
expect(aliceMessage2Reply.status.code).to.equal(202);
authorizeSpy.restore();

await Time.minimalSleep();
while (messageCids.length < 2) {
await Time.minimalSleep();
}

expect(authorizeSpy.callCount).to.equal(0, 'reauthorize'); // authorize is never called
expect(messageCids.length).to.equal(2, 'messageCids');
Expand Down Expand Up @@ -378,7 +380,9 @@ export function testSubscriptionScenarios(): void {
expect(aliceMessage2Reply.status.code).to.equal(202);
authorizeSpy.restore();

await Time.minimalSleep();
while (messageCids.length < 2) {
await Time.minimalSleep();
}

expect(authorizeSpy.callCount).to.equal(2, 'reauthorize'); // authorize on each message
expect(messageCids.length).to.equal(2, 'messageCids');
Expand Down Expand Up @@ -475,7 +479,9 @@ export function testSubscriptionScenarios(): void {
authorizeSpy.restore();
clock.restore();

await Time.minimalSleep();
while (messageCids.length < 3) {
await Time.minimalSleep();
}

expect(authorizeSpy.callCount).to.equal(1, 'reauthorize'); // called once after the TTL has passed
expect(messageCids.length).to.equal(3, 'messageCids');
Expand Down

0 comments on commit 4e7a507

Please sign in to comment.