London | 26-ITP-May | Russom Gebremeskel | Sprint 3 | 1 Implement and Rewrite Tests - #1529
London | 26-ITP-May | Russom Gebremeskel | Sprint 3 | 1 Implement and Rewrite Tests#1529russom-g wants to merge 14 commits into
Conversation
…f card rank and suits.
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.
File deleted as PR wasn't accepting it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| function getCardValue(card) { | ||
| // TODO: Implement this function | ||
| if (card <= 1 && card >= 10 || typeof card !== "string") { |
There was a problem hiding this comment.
please review the condition card <= 1 && card >= 10.
There was a problem hiding this comment.
Thank you for taking the time, reviewing my code and giving me feedback. I should have checked multiple times both the function and the tests before I did the pull request.
I have updated the if statement mow. The logic didn't make sense. I only kept the statement for checking not string.
| const rank = card.slice(0, -1); | ||
|
|
||
| if (!validRanks.includes(rank) || !validSuits.includes(suit)) { //Here the values that are stored in rank and suit are checked whether they are valid are inside the validRank and validSuits arrays. | ||
| return card + " Invalid card"; |
There was a problem hiding this comment.
Its better to throw an error here rather than returning the card + invalid string as an output of the function.
There was a problem hiding this comment.
I have changed it to throw error now
| }); | ||
|
|
||
| // Case 4: Invalid Cards | ||
| test(`Should return invalid cards when given a face card`, () => { |
There was a problem hiding this comment.
please review the test cases and make sure they are passing.
|
Closing PR because the May ITP run has finished. Feel free to re-open if you're still working on it. |
Learners, PR Template
Self checklist
Changelist
Multiple test cases written with Jest including special and edge cases prior to writing functions. Afterwards multiple functions implemented to cover for those tests. Some of the test were fixed or rewritten after finding issues.