Repository navigation
Manchester | 26-ITP-Sept | Rahana Suleiman | Sprint 2 | Implement and rewrite tests - #1702
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.
27995e0 to
02b9cb7
Compare
This comment has been minimized.
This comment has been minimized.
02b9cb7 to
6b39842
Compare
This comment has been minimized.
This comment has been minimized.
6b39842 to
8529aeb
Compare
This comment has been minimized.
This comment has been minimized.
8529aeb to
3e8c9c9
Compare
This comment has been minimized.
This comment has been minimized.
5055a01 to
21ded3e
Compare
| }); | ||
|
|
||
| test("Arbitrary non-card string", () => { | ||
| assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); |
There was a problem hiding this comment.
Is there a particular reason why you updated the provided test here?
|
|
||
| // Case 4: Invalid Cards | ||
| test("Should throw an error for arbitrary non-card strings", () => { | ||
| expect(() => getCardValue("invalid")).toThrow(); |
There was a problem hiding this comment.
Can you think of how these test that expect throw can be made more robust?
|
|
||
| // Right Angles (angle === 90°) | ||
| test("Classifies right angles", () => { | ||
| assert.equal(getAngleType(90), "Right angle"); |
There was a problem hiding this comment.
Can you spot another test that checks the same thing here?
| expect(getAngleType(1)).toEqual("Acute angle"); | ||
| expect(getAngleType(45)).toEqual("Acute angle"); | ||
| expect(getAngleType(89)).toEqual("Acute angle"); | ||
| expect(getAngleType(89.9)).toEqual("Acute angle"); |
There was a problem hiding this comment.
Nice idea to test decimals close to the boundary! Is there a particular reason to replace 89 rather than keep both values?
| throw new Error(`Expected a string, but got ${typeof card}`); | ||
| } | ||
|
|
||
| const cardRegex = /^(10|[2-9]|[AJQK])([♠♥♦♣])$/; |
|
Good job! Very clean implementations and thorough test coverage, especially around the boundaries. Apart from a couple of small issues with the provided tests and formatting - everything looks solid! |
|
Hi @webmonch , thank you so much for the helpful review and feedback! I have addressed the points you raised: getCardValue & getAngleType tests: Refactored the test assertions to ensure they are robust and cleaner, while keeping the boundary value checks thorough. Provided tests: Restored and respected the originally provided test cases as requested. The updates have been pushed and the PR is ready for another look. Thanks again for your time!" |
Self checklist
Task code
CYF-1059
Changelist
This PR implements the getAngleType, isProperFraction, and getCardValue functions alongside comprehensive unit test suites using both node:test and Jest to cover all standard, edge, and invalid input cases.