generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 261
West Midlands | 25-ITP-Sep | Baba Yusuf | Sprint 3 | coursework/sprint-3-implement-and-rewrite #796
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
Closed
Baba05206
wants to merge
11
commits into
CodeYourFuture:main
from
Baba05206:coursework/sprint-3-implement-and-rewrite
Closed
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c2ed214
checked npm install
Baba05206 1c09d41
Implement angle type identification in getAngleType function
Baba05206 7fd6b77
Add validation for denominator and expand test cases in isProperFract…
Baba05206 068c792
Implement card value calculation and error handling in getCardValue f…
Baba05206 ed99cda
Refactor angle type tests for clarity and completeness
Baba05206 0359872
Enhance test descriptions for isProperFraction function for clarity a…
Baba05206 a18d6db
Refactor tests for getCardValue function to enhance coverage and erro…
Baba05206 3975e54
Refactor getCardValue function to improve error handling and support …
Baba05206 e0d6ada
chore: add package.json for Jest test setup in rewrite-tests-with-jest
30ac3b1
Refactor getCardValue function to enhance handling of card ranks and …
debd986
Refactor isProperFraction function to improve zero denominator handli…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,50 @@ test("should return 11 for Ace of Spades", () => { | |
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return correct value for number cards (2–10)", () => { | ||
| expect(getCardValue("2♥")).toEqual(2); | ||
| expect(getCardValue("7♣")).toEqual(7); | ||
| expect(getCardValue("10♦")).toEqual(10); | ||
| expect(getCardValue("5♠")).toEqual(5); | ||
| }); | ||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for face cards (J, Q, K)", () => { | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("Q♦")).toEqual(10); | ||
| expect(getCardValue("K♥")).toEqual(10); | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| }); | ||
| // Case 4: Handle Ace (A): | ||
| test("should return 11 for Ace cards", () => { | ||
| expect(getCardValue("A♦")).toEqual(11); | ||
| expect(getCardValue("A♥")).toEqual(11); | ||
| expect(getCardValue("A♣")).toEqual(11); | ||
| expect(getCardValue("A♠")).toEqual(11); | ||
| }); | ||
| // Case 5: Handle Invalid Cards: | ||
| test("should throw an error for invalid card ranks and provide a descriptive message", () => { | ||
| // These specific ranks are all invalid | ||
| expect(() => getCardValue("Z♠")).toThrow( | ||
| 'Invalid or unrecognized card rank: "Z"' | ||
| ); | ||
| expect(() => getCardValue("1♥")).toThrow( | ||
| 'Invalid or unrecognized card rank: "1"' | ||
| ); | ||
| expect(() => getCardValue("11♦")).toThrow( | ||
| 'Invalid or unrecognized card rank: "11"' | ||
| ); | ||
| expect(() => getCardValue("X♣")).toThrow( | ||
| 'Invalid or unrecognized card rank: "X"' | ||
| ); | ||
|
|
||
| // These should throw because they result in an empty or whitespace rank | ||
| expect(() => getCardValue(" ♣")).toThrow( | ||
| 'Invalid or unrecognized card rank: " "' | ||
| ); | ||
| expect(() => getCardValue("♣")).toThrow( | ||
| 'Invalid or unrecognized card rank: ""' | ||
| ); | ||
|
Comment on lines
+34
to
+53
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. If you have time, you could also explore using a loop+array or |
||
| expect(() => getCardValue("")).toThrow( | ||
| 'Invalid or unrecognized card rank: ""' | ||
| ); | ||
Baba05206 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.