Skip to content

Commit

Permalink
Clear operation queue for operation repo tests
Browse files Browse the repository at this point in the history
Running tests consecutively that enqueue operations to the SubscriptionExecutor will fail due to the operationQueue length not matching the expected value. pushSubscription, smsSubscription, emailSubscription now point to the same SubscriptionExecutor and the operationQueue was not being cleared for the next test. The other tests don't fail but I also cleared the operation queue there too.
  • Loading branch information
shepherd-l committed Jul 8, 2024
1 parent 0eaf80e commit 3424f3d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions __test__/unit/core/operationRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ describe('OperationRepo tests', () => {
const executor =
operationRepo?.executorStore.store[ModelName.EmailSubscriptions];

executor._operationQueue = [];

modelRepo?.subscribe(() => {
broadcastCount += 1;
passIfBroadcastNTimes(1, broadcastCount, done);
Expand Down Expand Up @@ -106,6 +108,8 @@ describe('OperationRepo tests', () => {
const executor =
operationRepo?.executorStore.store[ModelName.EmailSubscriptions];

executor._operationQueue = [];

const processDeltaSpy = jest.spyOn(
OperationRepo.prototype as any,
'_processDelta',
Expand Down Expand Up @@ -142,6 +146,8 @@ describe('OperationRepo tests', () => {
const { modelRepo, operationRepo } = OneSignal.coreDirector.core;
const executor = operationRepo?.executorStore.store[ModelName.Identity];

executor._operationQueue = [];

const processDeltaSpy = jest.spyOn(
OperationRepo.prototype as any,
'_processDelta',
Expand Down Expand Up @@ -201,6 +207,8 @@ describe('OperationRepo tests', () => {
const { modelRepo, operationRepo } = OneSignal.coreDirector.core;
const executor = operationRepo?.executorStore.store[ModelName.Properties];

executor._operationQueue = [];

const processDeltaSpy = jest.spyOn(
OperationRepo.prototype as any,
'_processDelta',
Expand Down

0 comments on commit 3424f3d

Please sign in to comment.