-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23132b7
commit 429c52e
Showing
2 changed files
with
54 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 16 additions & 23 deletions
39
src/__tests__/check-that-getAuth0Client-throws-properly.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
import { createAuth0Client as mockedCreateAuth0 } from '__mocks__/@auth0/auth0-spa-js'; | ||
import { getAuth0Client, logoutAuth } from '~/utils/auth'; | ||
import { getAuth0Client } from '~/utils/auth'; | ||
|
||
test('getAuth0Client failed process', async () => { | ||
expect.assertions(1); | ||
mockedCreateAuth0.mockImplementation(() => { | ||
throw new Error(); | ||
describe('Auth0Client Errors Tests', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
try { | ||
await getAuth0Client(); | ||
} catch (e) { | ||
expect(e).toEqual(new Error(`getAuth0Client Error: Error`)); | ||
} | ||
}); | ||
test('getAuth0Client failed process', async () => { | ||
expect.assertions(1); | ||
|
||
test('logoutAuth failed process', async () => { | ||
expect.assertions(1); | ||
// @ts-ignore make logout fail with no .logout property on client | ||
mockedCreateAuth0.mockImplementation(() => { | ||
return {}; | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
require('@auth0/auth0-spa-js').Auth0Client.mockImplementation(() => { | ||
throw new Error(); | ||
}); | ||
|
||
try { | ||
await logoutAuth(); | ||
} catch (e) { | ||
expect(e).toEqual(new Error(`client_1.logout is not a function`)); | ||
} | ||
try { | ||
getAuth0Client(true); | ||
} catch (e) { | ||
expect(e).toEqual(new Error(`getAuth0Client Error: Error`)); | ||
} | ||
}); | ||
}); |