-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathindex.test.js
97 lines (84 loc) · 2.35 KB
/
index.test.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const currency = require('./');
const nock = require('nock');
beforeEach(() => {
nock('https://api.exchangeratesapi.io')
.get('/latest?base=USD')
.reply(200, {
'base': 'USD',
'rates': {
'EUR': 0.899
}
});
nock('https://api.exchangeratesapi.io')
.get('/latest?base=EUR')
.reply(200, {
'base': 'EUR',
'rates': {
'USD': 1.1122
}
});
nock('https://blockchain.info')
.get('/ticker')
.reply(200, {
'USD': {
'15m': 8944.49,
'last': 8944.49,
'buy': 8944.49,
'sell': 8944.49,
'symbol': '$'
},
'EUR': {
'15m': 8048.11,
'last': 8048.11,
'buy': 8048.11,
'sell': 8048.11,
'symbol': '€'
}
});
});
describe('currency', () => {
test('should convert 1 USD to EUR', async () => {
const converted = await currency({'amount': 1, 'from': 'USD', 'to': 'EUR'});
expect(converted).toBe(0.899);
});
test('should convert 1 USD to USD', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert 1 EUR to USD', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert 1 BTC to USD', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert 1 BTC to EUR', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert (with default values) without arguments', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert with amount only as argument', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should convert with amount and (from) currency only as arguments', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
test('should return errors message for unknown `from` or `to` currency value', async () => {
throw new Error(
'test not yet defined... remove the throw and write your test here'
);
});
});