-
-
Notifications
You must be signed in to change notification settings - Fork 337
Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Implement and rewrite tests #1197
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
1924ef4
a73fa1a
3d438c6
f6f394c
254abc7
1a4482e
aabad30
c555833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
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. Have you tested your implementation with this script?
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. yes and it passed
Contributor
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. Unless you have different files on your computer, I don't see how your function can pass this test. Both the function implementation and the tests have bugs.
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. ok ill fix those bugs, thanks
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. Altered function to pass failing test. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,34 @@ test(`Should return 11 when given an ace card`, () => { | |
| // Face Cards (J, Q, K) | ||
| // Invalid Cards | ||
|
|
||
| // Case 2: Face (J, Q, K) | ||
| test(`Should return 10 when given an face card`, () => { | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| }); | ||
|
|
||
| test(`Should return 10 when given an face card`, () => { | ||
| expect(getCardValue("Q♦")).toEqual(10); | ||
| }); | ||
|
|
||
| test(`Should return 10 when given an face card`, () => { | ||
| expect(getCardValue("K♥")).toEqual(10); | ||
| }); | ||
| // Case 3: Number Cards (2-10) | ||
| test(`Should return numerical value when given an number card`, () => { | ||
| expect(() => getCardValue("5")).toThrow("Error invalid card"); | ||
| }); | ||
|
Comment on lines
+29
to
+32
Contributor
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. Supposedly a valid card is a string in this format: "5" (without the suit character), would be considered an invalid card.
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. Thanks, ive changed that.
Contributor
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. Function implementation is correct. This test category is supposed for valid number cards. |
||
|
|
||
| test(`Should return error if the card string is invalid`, () => { | ||
| expect(() => getCardValue("17")).toThrow("Error invalid card"); | ||
| }); | ||
|
|
||
| // Case 4: Hex, Decimal Numbers | ||
| test(`Should return error if the rank is a hex input`, () => { | ||
| expect(() => getCardValue("0x02♠")).toThrow("Error invalid card"); | ||
| expect(() => getCardValue("2.1♠")).toThrow("Error invalid card"); | ||
| expect(() => getCardValue("0002♠")).toThrow("Error invalid card"); | ||
| }); | ||
|
|
||
| // To learn how to test whether a function throws an error as expected in Jest, | ||
| // please refer to the Jest documentation: | ||
| // https://jestjs.io/docs/expect#tothrowerror | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.