Manchester | 26-ITP-Jan | Liban Jama | Sprint 1 | Data Groups #1016
Manchester | 26-ITP-Jan | Liban Jama | Sprint 1 | Data Groups #1016libanj0161 wants to merge 15 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Sprint-1/implement/max.test.js
Outdated
| test("given an array including Nan return correct total", () => { | ||
| expect(findMax([11, NaN, 5])).toBe(11); | ||
| }); | ||
|
|
||
| // Given an array with numeric string value | ||
| // When passed to the max function | ||
| // Then it should ignore the numeric string and return correct total | ||
| test("given an array with numeric string value, it should ignore the numeric string and return correct total", () => { |
There was a problem hiding this comment.
The description of the expected return value are not quite correct.
| const input = ["a", "b", "c"]; | ||
| const result = dedupe(input); | ||
|
|
||
| expect(result).toEqual(input); | ||
| expect(result).not.toBe(input); |
There was a problem hiding this comment.
There is a chance that, even though result has incorrect elements (for example, []),
the two tests could still pass. Can you figure out why, and then fix the tests accordingly?
There was a problem hiding this comment.
Added .toHaveLength to ensure the returned array has the same number of elements as the original.
There was a problem hiding this comment.
This is better but it is still not 100% bullet proof. What if result is ["a", "b", "x"]?
There was a problem hiding this comment.
Can you update the test to ensure expected has the expected elements?
And optionally add another test to ensure input remains unchanged after the function call.
There was a problem hiding this comment.
From my research .toEqual already ensures the returned array has the exact expected elements. I also added an additional test to verify that calling the function does not change the original array.
|
|
||
| dedupe(input); | ||
|
|
||
| expect(input).toEqual(original); |
There was a problem hiding this comment.
You could combine this with the previous test.
Learners, PR Template
Self checklist
Changelist
Completed Fix under data groups module.
Questions
N/A.