Skip to content

Commit 37e70cb

Browse files
author
russom
committed
Test created for all the cases
1 parent 946461b commit 37e70cb

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,27 @@ const tally = require("./tally.js");
1919
// Given a function called tally
2020
// When passed an array of items
2121
// Then it should return an object containing the count for each unique item
22+
test("tally on an array returns an object with item", function() {
23+
expect(tally(["a"])).etEqual({a: 1})
24+
})
2225

2326
// Given an empty array
2427
// When passed to tally
2528
// Then it should return an empty object
26-
test.todo("tally on an empty array returns an empty object");
29+
test("tally on an empty array returns an empty object", function() {
30+
expect(tally([])).toEqual({})
31+
});
2732

2833
// Given an array with duplicate items
2934
// When passed to tally
3035
// Then it should return counts for each unique item
36+
test("tally on duplicate items returns count of items", function() {
37+
expect(tally(["a", "a", "a"])).toEqual({a: 3})
38+
})
3139

3240
// Given an invalid input like a string
3341
// When passed to tally
3442
// Then it should throw an error
43+
test("tally on invalid input throws an error", function() {
44+
expect(tally("string")).toBe("error")
45+
})

0 commit comments

Comments
 (0)