Skip to content

Commit eb7b89f

Browse files
committed
Add test to ensure dedupe returns a new array reference
1 parent 214e442 commit eb7b89f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sprint-1/implement/dedupe.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ test("given an array with no duplicates, it returns the same array", () => {
2727
expect(dedupe([1, 2, 3, 4, 5])).toEqual([1, 2, 3, 4, 5]);
2828
});
2929

30+
// When passed an array
31+
// It should not return the same array reference
32+
test("It returns a new array, not the original", () => {
33+
const original = [1, 2, 3];
34+
const result = dedupe(original);
35+
expect(result).not.toBe(original); // Check that the returned array is not the same reference as the original
36+
});
37+
3038
// Given an array with strings or numbers
3139
// When passed to the dedupe function
3240
// Then it should remove the duplicate values, preserving the first occurrence of each element

0 commit comments

Comments
 (0)