Skip to content

Commit

Permalink
10553: Use helper sleep method and avoid code duplication;
Browse files Browse the repository at this point in the history
  • Loading branch information
John Cruz committed Dec 13, 2024
1 parent 4d220ca commit f7a33fe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ import { RawUser } from '@shared/business/entities/User';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
import { mockPetitionerUser } from '@shared/test/mockAuthUsers';
import { petitionerUser } from '@shared/test/mockUsers';

function sleep(timeInMilliseconds: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(null);
}, timeInMilliseconds);
});
}
import { sleep } from '@shared/tools/helpers';

describe('queueEmailUpdateAssociatedCasesWorker', () => {
let TEST_USER: RawUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
handleLockError,
updateUserContactInformationInteractor,
} from './updateUserContactInformationInteractor';
import { sleep } from '@shared/tools/helpers';

const contactInfo = {
address1: '234 Main St',
Expand Down Expand Up @@ -63,14 +64,6 @@ describe('determineEntitiesToLock', () => {
});
});

function sleep(timeInMilliseconds: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(null);
}, timeInMilliseconds);
});
}

it('should wait until user is free before calling getCasesForUser', async () => {
let resolver: Function;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
mockPetitionsClerkUser,
mockPrivatePractitionerUser,
} from '@shared/test/mockAuthUsers';
import { sleep } from '@shared/tools/helpers';
import { validUser } from '../../../../../shared/src/test/mockUsers';

describe('Verify User Pending Email', () => {
Expand Down Expand Up @@ -308,14 +309,6 @@ describe('Verify User Pending Email', () => {
});

describe('verifyUserPendingEmailInteractor - Wait until User is free', () => {
function sleep(timeInMilliseconds: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(null);
}, timeInMilliseconds);
});
}

it('should wait until the user record is free to run the interactor', async () => {
let resolver: Function;
let errorMessage: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UserRecord } from '@web-api/persistence/dynamo/dynamoTypes';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
import { getUserByIdOnceAllUpdatesComplete } from '@web-api/persistence/dynamo/users/getUserByIdOnceAllUpdatesComplete';
import { sleep } from '@shared/tools/helpers';

describe('getUserByIdOnceAllUpdatesComplete', () => {
const TEST_USER_ID = 'TEST_USER_ID';
Expand Down Expand Up @@ -47,11 +48,3 @@ describe('getUserByIdOnceAllUpdatesComplete', () => {
expect(COMPLETE_FLAG).toEqual(true);
});
});

function sleep(timeInMilliseconds: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(null);
}, timeInMilliseconds);
});
}

0 comments on commit f7a33fe

Please sign in to comment.