-
Notifications
You must be signed in to change notification settings - Fork 308
/
Copy pathutils.test.ts
40 lines (32 loc) · 1.02 KB
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { getApiKeys } from '../../src/transport/utils'
import { config } from '../../src/config'
import { AdapterInputError } from '@chainlink/external-adapter-framework/validation/error'
describe('execute', () => {
const apiKey = 'fake-api-key'
const alterApiKey = 'fake-alter-api-key'
beforeAll(async () => {
config.initialize()
config.settings.API_KEY = apiKey
})
describe('no apiKey provided', () => {
it('should use default env variable', async () => {
const key = getApiKeys('', config.settings)
expect(key).toBe(apiKey)
})
})
describe('apiKey provided', () => {
it('should use apiKey', async () => {
process.env['KEY1_API_KEY'] = alterApiKey
const key = getApiKeys('KEY1', config.settings)
expect(key).toBe(alterApiKey)
})
})
describe('invalid apiKey provided', () => {
it('should throw exception', async () => {
const call = () => {
getApiKeys('KEY2', config.settings)
}
expect(call).toThrow(AdapterInputError)
})
})
})