1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-07 12:30:06 +00:00

test(get-token): covered getTokenRequestErrorPrefix

This commit is contained in:
Yury Shkoda
2023-06-21 16:34:26 +03:00
parent 375cec48ca
commit 28e9d1cc6b
6 changed files with 124 additions and 30 deletions

View File

@@ -1,9 +1,10 @@
import { AuthConfig } from '@sasjs/utils'
import { AuthConfig, ServerType } from '@sasjs/utils'
import * as NodeFormData from 'form-data'
import { generateToken, mockAuthResponse } from './mockResponses'
import { RequestClient } from '../../request/RequestClient'
import { refreshTokensForViya } from '../refreshTokensForViya'
import * as IsNodeModule from '../../utils/isNode'
import { getTokenRequestErrorPrefixResponse } from '../getTokenRequestErrorPrefix'
const requestClient = new (<jest.Mock<RequestClient>>RequestClient)()
@@ -67,9 +68,11 @@ describe('refreshTokensForViya', () => {
authConfig.client,
authConfig.secret,
authConfig.refresh_token
).catch((e: any) => e)
).catch((e: any) =>
getTokenRequestErrorPrefixResponse(e, ServerType.SasViya)
)
expect(error).toEqual(`Error while refreshing tokens: ${tokenError}`)
expect(error).toEqual(tokenError)
})
it('should throw an error if environment is not Node', async () => {