-
-
Notifications
You must be signed in to change notification settings - Fork 397
London | 26 - ITP-MAY | Ebrahim Moqbel | Sprint 3 | Implement and ewrite tests #1586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9eed6df
49b88ad
3c92b48
bfb2769
34ae0f2
5237b54
e75c8ba
12433ce
c9d4307
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well done on writing test cases for the border cases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,24 @@ test(`Should return 11 when given an ace card`, () => { | |
|
|
||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| test(`Should return the correct value for number cards (2-10)`, () => { | ||
| expect(getCardValue("2♠")).toEqual(2); | ||
| expect(getCardValue("5♠")).toEqual(5); | ||
| expect(getCardValue("10♠")).toEqual(10); | ||
| }) | ||
| // Face Cards (J, Q, K) | ||
| test(`Should return 10 when given a face card (J, Q, K)`, () => { | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("Q♠")).toEqual(10); | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| }) | ||
| // Invalid Cards | ||
| test(`Should throw an error when given an invalid card`, () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other invalid cases could you test (which other ranks are invalid and what about a missing rank)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added another case in line 27 for testing a missing rank. other invalid cases could be negative ranks. |
||
| expect(() => getCartValue("♠").toThrow("Invalid card")); | ||
| expect(() => getCardValue("5X")).toThrow("Invalid card "); //invalid suit | ||
| expect(() => getCardValue("1♠")).toThrow("Invalid card "); //invalid rank | ||
| expect(() => getCardValue("3")).toThrow("Invalid card "); //missing suit | ||
| }) | ||
|
Comment on lines
+26
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vs code shows me an error here. How can you fix it?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there was a closing curly bracket and parenthese in line 27. |
||
|
|
||
| // To learn how to test whether a function throws an error as expected in Jest, | ||
| // please refer to the Jest documentation: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of
+rank?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converting the string rank to a number.