From 376eadfbd7035aea5e10317bdd67b7e5a0df101c Mon Sep 17 00:00:00 2001 From: Israel Arcos Date: Fri, 3 May 2024 17:05:47 -0500 Subject: [PATCH] fix: fix unit tests --- packages/api-graphql/__tests__/GraphQLAPI-test.ts | 2 +- packages/auth/__tests__/auth-unit-test.ts | 2 +- packages/auth/src/Auth.ts | 4 +++- packages/datastore/package.json | 4 ++-- packages/predictions/__tests__/Predictions-unit-test.ts | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/api-graphql/__tests__/GraphQLAPI-test.ts b/packages/api-graphql/__tests__/GraphQLAPI-test.ts index bb659ceea1a..e0cd2481f13 100644 --- a/packages/api-graphql/__tests__/GraphQLAPI-test.ts +++ b/packages/api-graphql/__tests__/GraphQLAPI-test.ts @@ -757,7 +757,7 @@ describe('API test', () => { variables, authMode: GRAPHQL_AUTH_MODE.OPENID_CONNECT, }) - ).rejects.toThrowError('No federated jwt'); + ).rejects.toThrowError('No current user'); }); test('multi-auth using CUP as auth mode, but no userpool', async () => { diff --git a/packages/auth/__tests__/auth-unit-test.ts b/packages/auth/__tests__/auth-unit-test.ts index 93789a8a305..570dc655cba 100644 --- a/packages/auth/__tests__/auth-unit-test.ts +++ b/packages/auth/__tests__/auth-unit-test.ts @@ -3257,7 +3257,7 @@ describe('auth unit test', () => { Username: 'username', Pool: userPool, }); - const errorMessage = new NoUserPoolError(AuthErrorTypes.EmptyCode); + const errorMessage = new NoUserPoolError(AuthErrorTypes.MissingAuthConfig); expect.assertions(2); expect(auth.currentUserPoolUser().then()).rejects.toThrow( diff --git a/packages/auth/src/Auth.ts b/packages/auth/src/Auth.ts index 1f05e8c2e68..52e761f0cfa 100644 --- a/packages/auth/src/Auth.ts +++ b/packages/auth/src/Auth.ts @@ -1386,7 +1386,9 @@ export class AuthClass { logger.debug('Getting current session'); // Purposely not calling the reject method here because we don't need a console error if (!this.userPool) { - return Promise.reject(); + return Promise.reject(new NoUserPoolError( + AuthErrorTypes.MissingAuthConfig + )); } return new Promise((res, rej) => { diff --git a/packages/datastore/package.json b/packages/datastore/package.json index 9939669a459..9ec589c9489 100644 --- a/packages/datastore/package.json +++ b/packages/datastore/package.json @@ -43,8 +43,8 @@ "devDependencies": { "@react-native-community/netinfo": "4.7.0", "@types/uuid": "3.4.5", - "dexie": "3.0.3", - "dexie-export-import": "1.0.0-rc.2", + "dexie": "3.2.3", + "dexie-export-import": "1.0.3", "fake-indexeddb": "3.0.0" }, "dependencies": { diff --git a/packages/predictions/__tests__/Predictions-unit-test.ts b/packages/predictions/__tests__/Predictions-unit-test.ts index 9bbfa64fa56..ce67e4de2f5 100644 --- a/packages/predictions/__tests__/Predictions-unit-test.ts +++ b/packages/predictions/__tests__/Predictions-unit-test.ts @@ -353,7 +353,7 @@ describe('Predictions test', () => { predictions.convert(input, { providerName: 'WRONG_NAME' }); } catch (e) { expect(e.message).toMatch( - "Cannot read property 'convert' of undefined" + "Cannot read properties of undefined (reading 'convert')" ); } });