mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-12 22:50:06 +00:00
fix(refreshTokensForViya): added throw error if not Node
This commit is contained in:
@@ -3,6 +3,7 @@ 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'
|
||||
|
||||
const requestClient = new (<jest.Mock<RequestClient>>RequestClient)()
|
||||
|
||||
@@ -70,6 +71,18 @@ describe('refreshTokensForViya', () => {
|
||||
|
||||
expect(error).toEqual(`Error while refreshing tokens: ${tokenError}`)
|
||||
})
|
||||
|
||||
it('should throw an error if environment is not Node', async () => {
|
||||
jest.spyOn(IsNodeModule, 'isNode').mockImplementation(() => false)
|
||||
|
||||
const expectedError = new Error(
|
||||
`Method 'refreshTokensForViya' can only be used by Node.`
|
||||
)
|
||||
|
||||
expect(
|
||||
refreshTokensForViya(requestClient, 'client', 'secret', 'token')
|
||||
).rejects.toEqual(expectedError)
|
||||
})
|
||||
})
|
||||
|
||||
const setupMocks = () => {
|
||||
|
||||
Reference in New Issue
Block a user