-
-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathlookup.test.js
More file actions
58 lines (48 loc) · 1.35 KB
/
lookup.test.js
File metadata and controls
58 lines (48 loc) · 1.35 KB
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
const createLookup = require("./lookup.js");
describe("createLookup", () => {
[
{
input: [
["US", "USD"],
["CA", "CAD"],
["NJA", "NGN"],
["RSA", "RND"],
["UK", "GBP"],
],
expected: { US: "USD", CA: "CAD", NJA: "NGN", RSA: "RND", UK: "GBP" },
},
].forEach(({ input, expected }) =>
it(`Should return an object lookup of currency representing country code as keys`, () => {
expect(createLookup(input)).toEqual(expected);
})
);
[{ input: ["US", "USD", "CA", "CAD"], expected: "Invalid input" }].forEach(
({ input, expected }) =>
it(`should return "Invalid input" for any input not following the input format`, () => {
expect(createLookup(input)).toEqual(expected);
})
);
});
/*
Create a lookup object of key value pairs from an array of code pairs
Acceptance Criteria:
Given
- An array of arrays representing country code and currency code pairs
e.g. [['US', 'USD'], ['CA', 'CAD']]
When
- createLookup function is called with the country-currency array as an argument
Then
- It should return an object where:
- The keys are the country codes
- The values are the corresponding currency codes
Example
Given: [['US', 'USD'], ['CA', 'CAD']]
When
createLookup(countryCurrencyPairs) is called
Then
It should return:
{
'US': 'USD',
'CA': 'CAD'
}
*/