Repository navigation
Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 2 | implement and rewrite tests - #1667
salahalsabhi wants to merge 6 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hackertainment
left a comment
There was a problem hiding this comment.
The implementation looks good. Just need to design more unique/special/boundary test cases. Keep it up.
There was a problem hiding this comment.
While this is correct, I find it may be a bit hard to read. Sometimes using else if may look cleaner.
| test("corrctly get angle type", function(){ | ||
| assert.equal(getAngleType(400), "Invalid angle"); | ||
| }); |
There was a problem hiding this comment.
There should be two boundary cases for invalid angle. Can you think of them? Please add them back.
| test("Basic proper fraction", () => { | ||
| assert.equal(isProperFraction(-1, 2), true); | ||
| }); |
There was a problem hiding this comment.
Good coverage for positive numbers. However, there should be more test cases for negative numbers. Please add them. Thank you.
There was a problem hiding this comment.
For positive number cases, you have:
- numerator smaller than denominator
- numerator equal to denominator
- numerator greater than denominator
For zero cases, you have:
- numerator is zero
- denominator is zero
For mixed of positive and negative numbers, you have (-1, 2) and (1, -2) which means there are two combinations still not tested yet;
and for negative number cases, you just have (-1, -2) which also means one test is still missing.
You are almost there, so just add them back. Please let me know here in the comment if you cannot think of them. Thank you.
There was a problem hiding this comment.
There should be more test cases for negative numbers. Please add them. Thank you.
There was a problem hiding this comment.
Same as https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/pull/1667/changes/f8013884556d98db75c28911ac3d769f56cc59c5..432760649a19a4342ba768fe73a20a4ecc485703#r4239273199, and please add the missing test cases.
| }); | ||
|
|
||
|
|
||
| // TODO: What other invalid card cases can you think of? |
There was a problem hiding this comment.
What other invalid card cases can you think of? Please add them. Thank you.
| test(`Should return numeric value for number cards`, () => { | ||
| expect(getCardValue("2♥")).toEqual(2); | ||
| expect(getCardValue("9♠")).toEqual(9); | ||
| expect(getCardValue("10♦")).toEqual(10); | ||
| }); | ||
|
|
||
| test(`Should return 10 for face cards`, () => { | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| expect(getCardValue("Q♠")).toEqual(10); | ||
| expect(getCardValue("K♥")).toEqual(10); | ||
| }); |
There was a problem hiding this comment.
There should be one more special case for valid card. Please add it. Thank you.
| test(`Should throw for invalid cards`, () => { | ||
| expect(() => getCardValue("invalid")).toThrow( | ||
| /Expected a number followed by a suit, but got "invalid"/ | ||
| ); | ||
| expect(() => getCardValue("A")).toThrow( | ||
| /Expected a number followed by a suit/ | ||
| ); |
There was a problem hiding this comment.
There should be more invalid cards to test. Please add them. Thank you.
|
Thank you for the review, I did most of the notes you mentioned hope all good. |
|
All other updates looked good except the following two issues (which are basically the same):
Keep it up! |
|
Thanks for the feedback. I’ve added the missing cases: |
|
Well done. I hope you would now get a better idea on how to design good tests with maximum coverage but minimum number of cases. Just in case not, try to book a mentored coding session with a volunteer and discuss further about the unit test design process. |
Learners, PR Template
Self checklist
Task code
CYF-1059
Changelist
Implemented three functions and covered them with tests in both node:test and Jest.
Questions
No questions