Skip to content

Commit 1014ae0

Browse files
committed
Add tests for createLookup function to validate country-currency mapping and handle edge cases
1 parent c7406b2 commit 1014ae0

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎Sprint-2/implement/lookup.test.js‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
const createLookup = require("./lookup.js");
22

3-
test.todo("creates a country currency code lookup for multiple codes");
3+
describe("createLookup()", () => {
4+
test("creates a country currency code lookup for multiple codes", () => {
5+
const input = [
6+
["US", "USD"],
7+
["CA", "CAD"],
8+
["GB", "GBP"],
9+
];
10+
const expected = {
11+
US: "USD",
12+
CA: "CAD",
13+
GB: "GBP",
14+
};
15+
16+
expect(createLookup(input)).toEqual(expected);
17+
});
18+
19+
test("returns an empty object when passed an empty array", () => {
20+
expect(createLookup([])).toEqual({});
21+
});
22+
23+
test("returns an empty object when passed invalid inputs", () => {
24+
expect(createLookup(null)).toEqual({});
25+
expect(createLookup("invalid")).toEqual({});
26+
});
27+
});
428

529
/*
630

0 commit comments

Comments
 (0)