Skip to content

Commit fa5733b

Browse files
committed
Add tests for dedupe function to validate behavior with various inputs
1 parent 9996283 commit fa5733b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎Sprint-1/implement/dedupe.test.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,26 @@ E.g. dedupe([1, 2, 1]) returns [1, 2]
1616
// Given an empty array
1717
// When passed to the dedupe function
1818
// Then it should return an empty array
19-
test.todo("given an empty array, it returns an empty array");
19+
test("given an empty array, it returns an empty array", () => {
20+
expect(dedupe([])).toEqual([]);
21+
});
2022

2123
// Given an array with no duplicates
2224
// When passed to the dedupe function
2325
// Then it should return a copy of the original array
26+
test("given an array with no duplicates it returns copy of original array", () => {
27+
expect(dedupe([1, 2, 3, 4])).toEqual([1, 2, 3, 4]);
28+
});
2429

2530
// Given an array of strings or numbers
2631
// When passed to the dedupe function
27-
// Then it should return a new array with duplicates removed while preserving the
32+
// Then it should return a new array with duplicates removed while preserving the
2833
// first occurrence of each element from the original array.
34+
test("given an array with duplicates of strings and numbers it returns first occurrence of each element", () => {
35+
expect(dedupe([1, "ball", "ball", 3, 1, "egg"])).toEqual([
36+
1,
37+
"ball",
38+
3,
39+
"egg",
40+
]);
41+
});

0 commit comments

Comments
 (0)