-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrencySymbolMap.test.js
50 lines (41 loc) · 1.5 KB
/
currencySymbolMap.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
const getSymbolFromCurrency = require('./');
const currencySymbolMap = require('./map');
test('Should return $ when USD is provided', () => {
let result = getSymbolFromCurrency('USD');
expect(result).toBe('$');
});
test('Should return £ when GBP is provided', () => {
let result = getSymbolFromCurrency('GBP');
expect(result).toBe('£');
});
test('Should return € when EUR is provided', () => {
let result = getSymbolFromCurrency('EUR');
expect(result).toBe('€');
});
test('Should return € when eur is provided', () => {
let result = getSymbolFromCurrency('eur');
expect(result).toBe('€');
});
test('Should return undefined when code is non-existent', () => {
let result = getSymbolFromCurrency('NON-EXISTENT-CODE');
expect(result).toBe.undefined;
});
test('Should return undefined when param is not a string', () => {
let result = getSymbolFromCurrency(1);
expect(result).toBe.undefined;
});
test('Should return undefined when param is false', () => {
let result = getSymbolFromCurrency(false);
expect(result).toBe.undefined;
});
test('Should return undefined when param is undefined', () => {
let result = getSymbolFromCurrency(false);
expect(result).toBe.undefined;
});
test('Sanity check every value in map', () => {
const currencies = Object.keys(currencySymbolMap);
const hasFalseyValues = currencies.some(item => {
return currencySymbolMap[item] !== getSymbolFromCurrency(item);
});
expect(hasFalseyValues).toEqual(false);
});