Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 398
London | 26-ITP-May | Jorvan White | Sprint 3 | Implement and Rewrite Tests#1601
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?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4c62400376a6b02323e1087fbee557e3a65bf5c3324ca3f91185c7e7195189a3f957a1b48031e216221ad10fc3c60638b42ac2702f8cf7cff3f69dbf6f3d1d0bdef75630c50255740a46994606e54bbd59aaaa7e7cacfb4a6131aba85a823cc958de919dba46e8fedad9b6d56e20bb70a41e976836cce7de9d15898795fb4d941ff4d681c0b8af367e7dcd78File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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. there should be more negative number test cases. Can you think of them? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,11 +10,62 @@ test(`Should return 11 when given an ace card`, () => { | ||
| }); | ||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| // Face Cards (J, Q, K) | ||
| // Case 2: Number Cards (2-10) | ||
| test(`Should return the same number when given a number card of any suit`, () => { | ||
| expect(getCardValue("3♠")).toEqual(3); | ||
| expect(getCardValue("5♥")).toEqual(5); | ||
| expect(getCardValue("9♦")).toEqual(9); | ||
| expect(getCardValue("10♣")).toEqual(10); | ||
| }); | ||
| // Case 3: Valid Suits | ||
| test("Should accept all valid suits", () => { | ||
| expect(getCardValue("A♠")).toEqual(11); | ||
| expect(getCardValue("A♥")).toEqual(11); | ||
| expect(getCardValue("A♦")).toEqual(11); | ||
| expect(getCardValue("A♣")).toEqual(11); | ||
| }); | ||
| // Case 4: Face Cards (J, Q, K) | ||
| test(`Should return 10 when given an any face card`, () => { | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("Q♥")).toEqual(10); | ||
| expect(getCardValue("K♦")).toEqual(10); | ||
| }); | ||
| // Invalid Cards | ||
| // Test 5: Non-suit inputs | ||
| test("Cards without suits throw an error", () => { | ||
| expect(() => { | ||
| getCardValue("10"); | ||
| }).toThrow("Invalid card"); | ||
| }); | ||
Comment on lines
+37
to
+44
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 should be more invalid cases, Can you think of them? | ||
| // Test 6: Invalid suits | ||
| test("Should throw an error for an invalid suit", () => { | ||
| expect(() => getCardValue("A★")).toThrow("Invalid card"); | ||
| }); | ||
| // Test 7: Invalid rank | ||
| test("Should throw an error for an invalid rank", () => { | ||
| expect(() => getCardValue("Z♠")).toThrow("Invalid card"); | ||
| }); | ||
| // Test 8: Invalid input | ||
| test("Should throw an error for an invalid card", () => { | ||
| expect(() => getCardValue("hello")).toThrow("Invalid card"); | ||
| }); | ||
| // Test 9: Reject lowercase card ranks | ||
| test("Should reject lowercase card ranks", () => { | ||
| expect(() => getCardValue("a♠")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("j♠")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("q♠")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("k♠")).toThrow("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.
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.
Besides
-1and361, it should include the two boundary cases as well.