Skip to content

Commit f15a043

Browse files
committed
Completed the test todo
1 parent d5fc0d6 commit f15a043

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

Sprint-2/implement/lookup.test.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
const createLookup = require("./lookup.js");
22

3-
test.todo("creates a country currency code lookup for multiple codes");
4-
test.todo("creates a country currency code lookup for an empty array");
5-
test.todo("creates a country currency code lookup for duplicate country codes");
6-
test.todo("creates a country currency code lookup for invalid input");
3+
test("creates a country currency code lookup for single code");
4+
const input = [['US','USD'], ['CA','CAD']];
5+
const result = createLookup(input);
6+
expect(result).toEqual({
7+
'US': 'USD',
8+
'CA': 'CAD'
9+
});
10+
11+
test("creates a country currency code lookup for an empty array", () => {
12+
const result = createLookup([]);
13+
14+
expect(result).toEqual({});
15+
});
16+
17+
18+
test("creates a country currency code lookup for duplicate country codes", () => {
19+
const input = [
20+
["US", "USD"],
21+
["US", "USN"],
22+
];
23+
const result = createLookup(input);
24+
25+
expect(result).toEqual({
26+
US: "USN",
27+
});
28+
});
29+
30+
test("creates a country currency code lookup for duplicate country codes", () => {
31+
const input = [
32+
["US", "USD"],
33+
["US", "USN"],
34+
];
35+
const result = createLookup(input);
36+
37+
expect(result).toEqual({
38+
US: "USN",
39+
});
40+
});
41+
42+
test("creates a country currency code lookup for invalid input", () => {
43+
expect(() => createLookup(null)).toThrow();
44+
expect(() => createLookup(123)).toThrow();
45+
expect(() => createLookup("invalid input")).toThrow();
46+
});
747

848
/*
949

0 commit comments

Comments
 (0)