Skip to content

Commit fbce304

Browse files
committed
wrte tests
1 parent 6d8eefd commit fbce304

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ const tally = require("./tally.js");
2323
// Given an empty array
2424
// When passed to tally
2525
// Then it should return an empty object
26-
test.todo("tally on an empty array returns an empty object");
26+
test("tally on an empty array returns an empty object", () => {
27+
expect(tally([])).toEqual({});
28+
});
2729

2830
// Given an array with duplicate items
2931
// When passed to tally
3032
// Then it should return counts for each unique item
33+
test("tally on an array with duplicate items returns counts for each unique item", () => {
34+
expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 });
35+
});
3136

3237
// Given an invalid input like a string
3338
// When passed to tally
3439
// Then it should throw an error
40+
test("tally on an invalid input like a string throws an error", () => {
41+
expect(() => tally("invalid input")).toThrow("Invalid input");
42+
});

0 commit comments

Comments
 (0)