mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-15 16:10:06 +00:00
test(session): add assertion of get request quantity
This commit is contained in:
@@ -54,19 +54,18 @@ describe('SessionManager', () => {
|
|||||||
|
|
||||||
it('should reject with NoSessionStateError if SAS server did not provide session state', async () => {
|
it('should reject with NoSessionStateError if SAS server did not provide session state', async () => {
|
||||||
let requestAttempt = 0
|
let requestAttempt = 0
|
||||||
|
const requestAttemptLimit = 10
|
||||||
|
|
||||||
mockedAxios.get.mockImplementation(() => {
|
mockedAxios.get.mockImplementation(() => {
|
||||||
requestAttempt += 1
|
requestAttempt += 1
|
||||||
|
|
||||||
if (requestAttempt > 10) {
|
if (requestAttempt >= requestAttemptLimit) {
|
||||||
return Promise.resolve({ data: 'idle', status: 200 })
|
return Promise.resolve({ data: 'idle', status: 200 })
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve({ data: '', status: 304 })
|
return Promise.resolve({ data: '', status: 304 })
|
||||||
})
|
})
|
||||||
|
|
||||||
mockedAxios
|
|
||||||
|
|
||||||
jest.spyOn((process as any).logger, 'info')
|
jest.spyOn((process as any).logger, 'info')
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@@ -91,6 +90,7 @@ describe('SessionManager', () => {
|
|||||||
expect((process as any).logger.info).toHaveBeenLastCalledWith(
|
expect((process as any).logger.info).toHaveBeenLastCalledWith(
|
||||||
`Could not get session state. Server responded with 304 whilst checking state: ${process.env.SERVER_URL}`
|
`Could not get session state. Server responded with 304 whilst checking state: ${process.env.SERVER_URL}`
|
||||||
)
|
)
|
||||||
|
expect(mockedAxios.get).toHaveBeenCalledTimes(requestAttemptLimit)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user