Skip to content

Commit f786fca

Browse files
committed
Fix: Add reference check to dedupe copy test
1 parent 31bcc22 commit f786fca

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Sprint-1/implement/dedupe.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ test("given an empty array, it returns an empty array", () => {
2323
// Given an array with no duplicates
2424
// When passed to the dedupe function
2525
// Then it should return a copy of the original array
26-
test("given an araay with no duplicates, it returns a copy of the original array", () => {
27-
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
28-
expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]);
26+
test("given an array with no duplicates, it returns a copy of the original array", () => {
27+
const input = [1, 2, 3];
28+
const result = dedupe(input);
29+
// Check the contents are the same
30+
expect(result).toEqual(input);
31+
// Check it's a different array, not the same reference
32+
expect(result).not.toBe(input);
2933
});
3034

3135
// Given an array with strings or numbers

0 commit comments

Comments
 (0)