Skip to content

Commit

Permalink
fail the test when not called with true
Browse files Browse the repository at this point in the history
  • Loading branch information
RemoLiechti committed Sep 27, 2024
1 parent 3c12842 commit 07d5c36
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/token-helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,23 @@ test('getToken - string (jwt) with local=true', async () => {

// Mock _persistTokens to use local=true
const originalPersistTokens = IMS_TOKEN_MANAGER._persistTokens
IMS_TOKEN_MANAGER._persistTokens = jest.fn((context, contextData, resultPromise, local) => {
const persistTokensMock = jest.fn((context, contextData, resultPromise, local) => {
return originalPersistTokens.call(IMS_TOKEN_MANAGER, context, contextData, resultPromise, true)
})
IMS_TOKEN_MANAGER._persistTokens = persistTokensMock

// no force
await expect(IMS_TOKEN_MANAGER.getToken(contextName, false)).resolves.toEqual('abc123')

// force
await expect(IMS_TOKEN_MANAGER.getToken(contextName, true)).resolves.toEqual('abc123')

// Verify that _persistTokens was called with local=true
expect(persistTokensMock).toHaveBeenCalled()
persistTokensMock.mock.calls.forEach(call => {
expect(call[3]).toBe(true)
})

// Restore the original _persistTokens method
IMS_TOKEN_MANAGER._persistTokens = originalPersistTokens
})
Expand Down

0 comments on commit 07d5c36

Please sign in to comment.