Test Failed
Push — main ( e93202...ec58f7 )
by Yuri
01:18
created

test/acceptance.test.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 36
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
mnd 1
bc 1
fnc 0
dl 0
loc 36
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { getExchangeRate } from '../src'
2
3
const shouldRunAcceptanceTests = process.env.RUN_ACCEPTANCE_TESTS === 'true'
4
const runOrSkip = shouldRunAcceptanceTests ? describe : describe.skip
5
runOrSkip('getExchangeRate acceptance tests', () => {
6
7
  jest.setTimeout(30 * 1000)
8
9
  it('should return exchange rate for real API call', async () => {
10
    const rate = await getExchangeRate('USD', 'EUR')
11
12
    console.log(`1 USD = ${rate} EUR`)
13
    expect(rate).toBeGreaterThan(0)  // Basic check, as the actual rate will vary
14
  })
15
16
  it('should handle requests for multiple currency pairs', async () => {
17
    const rates = await Promise.all([
18
      getExchangeRate('USD', 'EUR'),
19
      getExchangeRate('USD', 'GBP'),
20
      getExchangeRate('USD', 'JPY'),
21
    ])
22
23
    console.log(`1 USD = ${rates[0]} EUR`)
24
    console.log(`1 USD = ${rates[1]} GBP`)
25
    console.log(`1 USD = ${rates[2]} JPY`)
26
27
    rates.forEach(rate => {
28
      expect(rate).toBeGreaterThan(0)
29
    })
30
  })
31
32
  it('should throw an error for unknown currency codes', async () => {
33
    await expect(getExchangeRate('USD', 'ZZZ')).rejects.toThrow()
34
  })
35
})
36