Skip to content

Commit cd36e17

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
pr changes made
1 parent 350ad2e commit cd36e17

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

Sprint-1/implement/dedupe.test.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,43 @@ E.g. dedupe([1, 2, 1]) returns [1, 2]
1717
// When passed to the dedupe function
1818
// Then it should return an empty array
1919
describe("dedupe", () => {
20-
[
21-
{ input: [], expected: [] },
22-
].forEach(({ input, expected }) =>
23-
it(`returns empty array for [${input}]`, () => expect(dedupe(input)).toEqual(expected))
20+
[{ input: [], expected: [] }].forEach(({ input, expected }) =>
21+
it(`returns empty array for [${input}]`, () =>
22+
expect(dedupe(input)).toEqual(expected))
2423
);
2524

26-
27-
// Given an array with no duplicates
28-
// When passed to the dedupe function
29-
// Then it should return a copy of the original array
25+
// Given an array with no duplicates
26+
// When passed to the dedupe function
27+
// Then it should return a copy of the original array
3028

3129
[
3230
{ input: [1, 2, 3], expected: [1, 2, 3] },
3331
{ input: [3, 2, 1, 4, 5], expected: [3, 2, 1, 4, 5] },
3432
{ input: ["hello", "a", "b", "c"], expected: ["hello", "a", "b", "c"] },
3533
{ input: [1, 2, "hello", 4, "a", 6], expected: [1, 2, "hello", 4, "a", 6] },
36-
].forEach(({ input, expected }) =>
37-
it(`returns the median for [${input}]`, () => expect(dedupe(input)).toEqual(expected))
38-
);
39-
40-
// Given an array of strings or numbers
41-
// When passed to the dedupe function
42-
// Then it should return a new array with duplicates removed while preserving the
43-
// first occurrence of each element from the original array.
34+
].forEach(({ input, expected }) => {
35+
it(`returns array with same contents for [${input}]`, () =>
36+
expect(dedupe(input)).toEqual(expected));
37+
it(`returns a non-identical array (copy) for [${input}]`, () =>
38+
expect(dedupe(input)).not.toBe(input));
39+
});
40+
41+
// Given an array of strings or numbers
42+
// When passed to the dedupe function
43+
// Then it should return a new array with duplicates removed while preserving the
44+
// first occurrence of each element from the original array.
4445

4546
[
46-
{ input: [1, 1, 2, 2, 3, 3,], expected: [1, 2, 3] },
47+
{ input: [1, 1, 2, 2, 3, 3], expected: [1, 2, 3] },
4748
{ input: ["a", "a", "b", "b", "c", "c"], expected: ["a", "b", "c"] },
48-
{ input: ["qwe", "qwe", 3, 3, "hello", "hello" , "hello"], expected: ["qwe", 3, "hello"] },
49+
{
50+
input: ["qwe", "qwe", 3, 3, "hello", "hello", "hello"],
51+
expected: ["qwe", 3, "hello"],
52+
},
4953
{ input: ["a", "a", "a", "a"], expected: ["a"] },
5054
{ input: [1, 2, 2, 2, 2, 2], expected: [1, 2] },
5155
].forEach(({ input, expected }) =>
52-
it(`returns the median for [${input}]`, () => expect(dedupe(input)).toEqual(expected))
56+
it(`returns no duplicates for [${input}]`, () =>
57+
expect(dedupe(input)).toEqual(expected))
5358
);
54-
});
59+
});

Sprint-1/implement/max.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function findMax(list) {
22
const numbers = list.filter((n) => Number.isFinite(n));
33
if (numbers.length == 0) {
4-
return "-Infinity";
4+
return -Infinity;
55
} else {
66
return Math.max(...numbers);
77
}

Sprint-1/implement/max.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("calculateMedian", () => {
2020

2121
it("empty array returns -Infinity", () => {
2222
const list = [];
23-
expect(findMax(list)).toEqual("-Infinity");
23+
expect(findMax(list)).toEqual(-Infinity);
2424
});
2525

2626
// Given an array with one number
@@ -74,6 +74,6 @@ describe("calculateMedian", () => {
7474

7575
it("array with only non-number values, return the least surprising value given how it behaves for all other inputs", () => {
7676
const list = ["a", "b", "c"];
77-
expect(findMax(list)).toEqual("-Infinity");
77+
expect(findMax(list)).toEqual(-Infinity);
7878
});
7979
});

0 commit comments

Comments
 (0)