From a4ebe2350db06d9a62c86158b2d105b4dccbafee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kowalczyk?= <37898730+lkowalczyk87@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:42:10 +0200 Subject: [PATCH] fix google auth for pure (#1993) --- .../contacts/actions/authorize.action.test.ts | 15 +++++++++++++++ libs/core/contacts/actions/authorize.action.ts | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libs/core/contacts/actions/authorize.action.test.ts b/libs/core/contacts/actions/authorize.action.test.ts index 54e0e7d904..192e12c473 100644 --- a/libs/core/contacts/actions/authorize.action.test.ts +++ b/libs/core/contacts/actions/authorize.action.test.ts @@ -19,6 +19,9 @@ jest.mock("generic-view/store", () => { googleAuthorize: () => ({ type: fulfilledAction("generic-imports/google-authorization-process"), + unwrap: jest.fn().mockResolvedValue({ + type: fulfilledAction("generic-imports/google-authorization-process"), + }), } as unknown as jest.Mock), } }) @@ -41,6 +44,18 @@ describe("async `authorize` ", () => { authorize(Provider.Google) as unknown as AnyAction ) + const actions = mockStore.getActions() + + const googleAuthorizeAction = actions.find( + (action) => + action.type === + "generic-imports/google-authorization-process/fulfilled" + ) + + if (googleAuthorizeAction) { + delete googleAuthorizeAction.unwrap + } + expect(mockStore.getActions()).toEqual([ authorize.pending(requestId, Provider.Google), { diff --git a/libs/core/contacts/actions/authorize.action.ts b/libs/core/contacts/actions/authorize.action.ts index 23e3fc85d2..e9028c9fdc 100644 --- a/libs/core/contacts/actions/authorize.action.ts +++ b/libs/core/contacts/actions/authorize.action.ts @@ -24,11 +24,11 @@ export const authorize = createAsyncThunk< >(ContactsEvent.Authorize, async (payload, { dispatch }) => { switch (payload) { case Provider.Google: - return dispatch(googleAuthorize(Scope.Contacts)) + return dispatch(googleAuthorize(Scope.Contacts)).unwrap() case Provider.Apple: return undefined case Provider.Outlook: - return dispatch(outlookAuthorize(OutLookScope.Contacts)) + return dispatch(outlookAuthorize(OutLookScope.Contacts)).unwrap() default: return undefined }