Skip to content

Commit 8958df6

Browse files
committed
all test pass
1 parent 1067570 commit 8958df6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Sprint-1/implement/dedupe.test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@ E.g. dedupe([5, 1, 1, 2, 3, 2, 5, 8]) target output: [5, 1, 2, 3, 8]
1111
E.g. dedupe([1, 2, 1]) target output: [1, 2]
1212
*/
1313

14+
1415
// Acceptance Criteria:
1516

1617
// Given an empty array
1718
// When passed to the dedupe function
1819
// Then it should return an empty array
19-
test.todo("given an empty array, it returns an empty array");
20-
20+
test("given an empty array, it returns an empty array",() => {
21+
expect(dedupe([])).toEqual([]);
22+
});
23+
2124
// Given an array with no duplicates
2225
// When passed to the dedupe function
2326
// Then it should return a copy of the original array
27+
test("returns the same array if there are no duplicates", () => {
28+
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
29+
});
2430

2531
// Given an array with strings or numbers
2632
// When passed to the dedupe function
2733
// Then it should remove the duplicate values, preserving the first occurence of each element
34+
it("removes duplicates and keeps the first occurrence", () => {
35+
expect(dedupe([1, 2, 1, 3, 2])).toEqual([1, 2, 3]);
36+
expect(dedupe(["a", "a", "b", "a", "c"])).toEqual(["a", "b", "c"]);
37+
});
38+

0 commit comments

Comments
 (0)