Skip to content

Commit 4505215

Browse files
committed
test duplicates
1 parent 537830e commit 4505215

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Sprint-1/implement/dedupe.test.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@ E.g. dedupe(['a','a','a','b','b','c']) target output: ['a','b','c']
1010
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
*/
13-
13+
describe("dedupe", () => {
14+
test("given an array with duplicates, it deduplicate the elements of an array", () => {
15+
expect(dedupe([1, 2, 1])).toEqual([1, 2]);
16+
expect(dedupe(["a", "a", "b", "b", "c"])).toEqual(["a", "b", "c"]);
17+
expect(dedupe([5, 1, 1, 2, 3, 2, 5, 8])).toEqual([5, 1, 2, 3, 8]);
18+
});
1419
// Acceptance Criteria:
1520

1621
// Given an empty array
1722
// When passed to the dedupe function
1823
// Then it should return an empty array
19-
test.todo("given an empty array, it returns an empty array");
24+
test("given an empty array, it returns an empty array", () => {
25+
expect(dedupe([])).toEqual([]);
26+
});
2027

21-
// Given an array with no duplicates
28+
// Given an array with no duplicatesgo directly to implementing it step by step
2229
// When passed to the dedupe function
2330
// Then it should return a copy of the original array
2431

2532
// Given an array with strings or numbers
2633
// When passed to the dedupe function
2734
// Then it should remove the duplicate values, preserving the first occurence of each element
35+
test("given an array with no duplicates, it returns a copy of the original array", () => {
36+
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
37+
expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]);
38+
});
39+
});
40+
41+
42+
43+

0 commit comments

Comments
 (0)