From 95d41e936105311428a3515686a6f41a896f3ead Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 12 Feb 2023 02:42:30 +0200 Subject: [PATCH] TuitioState's token property can be null --- README.md | 3 ++- src/__tests__/TuitioAuthentication.test.ts | 2 +- src/client.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9552631..5db4ea5 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,5 @@ All tests in the package can be executed by running: `npm test`. 1.0.0 - Package initialization 1.0.1 - Export Tuitio types 1.0.2 - Validate that Tuitio's URL parameter is a valid URL -1.0.3 - Added LICENSE file +1.0.3 - Added LICENSE file +1.0.4 - TuitioState's token property can be null diff --git a/src/__tests__/TuitioAuthentication.test.ts b/src/__tests__/TuitioAuthentication.test.ts index 54a3415..f648ecb 100644 --- a/src/__tests__/TuitioAuthentication.test.ts +++ b/src/__tests__/TuitioAuthentication.test.ts @@ -24,7 +24,7 @@ test("Tuitio client authentication", async () => { expect(result.status).toBe("_MOCK_"); const storage = fetch(); - expect(storage.token.raw).toBe("mock-user-pass"); + expect(storage.token?.raw).toBe("mock-user-pass"); expect(storage.userName).toBe("user"); invalidate(); diff --git a/src/client.ts b/src/client.ts index b6848f9..35ba608 100644 --- a/src/client.ts +++ b/src/client.ts @@ -58,7 +58,7 @@ const invalidate = (): void => { } }; -export type TuitioState = { token: TuitioToken; userName: string }; +export type TuitioState = { token: TuitioToken | null; userName: string }; const fetch = (): TuitioState => { const data = {