From 3b089c749602a3ca6bb250c5288547c5f31fe80c Mon Sep 17 00:00:00 2001 From: Mathieu Artu Date: Mon, 28 Oct 2024 11:33:27 +0100 Subject: [PATCH] feat: share the same user storage mock instance in tests --- test/e2e/tests/notifications/mocks.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/e2e/tests/notifications/mocks.ts b/test/e2e/tests/notifications/mocks.ts index 2bd6847a0e72..ce2ced3df210 100644 --- a/test/e2e/tests/notifications/mocks.ts +++ b/test/e2e/tests/notifications/mocks.ts @@ -20,11 +20,11 @@ type MockResponse = { * E2E mock setup for notification APIs (Auth, UserStorage, Notifications, Push Notifications, Profile syncing) * * @param server - server obj used to mock our endpoints - * @param userStorageMockttpController - optional controller to mock user storage endpoints + * @param userStorageMockttpControllerInstance - optional instance of UserStorageMockttpController, useful if you need persisted user storage between tests */ export async function mockNotificationServices( server: Mockttp, - userStorageMockttpController?: UserStorageMockttpController, + userStorageMockttpControllerInstance: UserStorageMockttpController = new UserStorageMockttpController(), ) { // Auth mockAPICall(server, AuthMocks.getMockAuthNonceResponse()); @@ -32,14 +32,14 @@ export async function mockNotificationServices( mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse()); // Storage - if (!userStorageMockttpController?.paths.get('accounts')) { - new UserStorageMockttpController().setupPath('accounts', server); + if (!userStorageMockttpControllerInstance?.paths.get('accounts')) { + userStorageMockttpControllerInstance.setupPath('accounts', server); } - if (!userStorageMockttpController?.paths.get('networks')) { - new UserStorageMockttpController().setupPath('networks', server); + if (!userStorageMockttpControllerInstance?.paths.get('networks')) { + userStorageMockttpControllerInstance.setupPath('networks', server); } - if (!userStorageMockttpController?.paths.get('notifications')) { - new UserStorageMockttpController().setupPath('notifications', server); + if (!userStorageMockttpControllerInstance?.paths.get('notifications')) { + userStorageMockttpControllerInstance.setupPath('notifications', server); } // Notifications