1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

test(session): add assertion of get request quantity

This commit is contained in:
Yury Shkoda
2021-07-27 16:06:43 +03:00
parent 0b9284e481
commit ac8821baec

View File

@@ -54,19 +54,18 @@ describe('SessionManager', () => {
it('should reject with NoSessionStateError if SAS server did not provide session state', async () => {
let requestAttempt = 0
const requestAttemptLimit = 10
mockedAxios.get.mockImplementation(() => {
requestAttempt += 1
if (requestAttempt > 10) {
if (requestAttempt >= requestAttemptLimit) {
return Promise.resolve({ data: 'idle', status: 200 })
}
return Promise.resolve({ data: '', status: 304 })
})
mockedAxios
jest.spyOn((process as any).logger, 'info')
await expect(
@@ -91,6 +90,7 @@ describe('SessionManager', () => {
expect((process as any).logger.info).toHaveBeenLastCalledWith(
`Could not get session state. Server responded with 304 whilst checking state: ${process.env.SERVER_URL}`
)
expect(mockedAxios.get).toHaveBeenCalledTimes(requestAttemptLimit)
})
})
})