Repository navigation
London | 26-ITP-Sep | Mars Adesina | Sprint 2 | Implement and rewrite tests #1718
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
Open
marscancode
wants to merge
24
commits into
CodeYourFuture:main
Choose a base branch
from
marscancode:coursework/sprint-3-implement-and-rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3c34300
implemented getAngleType function
marscancode a3e94a4
implemented right angle classification
marscancode e24692a
added Obtuse angle test
marscancode 9aafc79
added straight angle test it fails
marscancode db06ff6
implemented classification for straight angle test now passes
marscancode 2e539b5
added reflex angle test and it fails
marscancode 874aa37
implemented classification for reflex angle test now passes
marscancode 190c45b
added test for invalid angles it fails
marscancode 5bf0d70
added test for acute angle
marscancode 9faf227
refactored acute angle implementation
marscancode b7ac8b6
added additional acute angle tests
marscancode f5f0c00
refactored aditional acute angle tests
marscancode 780ce9a
added additional tests for obtuse angles
marscancode d242353
added additional tests for reflex angles
marscancode ff0d518
added additonal tests for invalid angles
marscancode f049f47
added final test for invalid angle 360
marscancode 036f167
added final acute angle test for 1
marscancode 8631a7e
added jest tests
marscancode 7797f0c
added tests in node for isProperFraction function
marscancode 5651ef6
Implemented isProperFraction function
marscancode d47c1c7
added tests in jest for the isProperFraction function
marscancode 57a3aba
Implemented getCardValue function
marscancode 7d65d6f
added node tests for getCardValue function
marscancode f989cbd
added jest test for getCardValue function
marscancode 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
Some comments aren't visible on the classic Files Changed page.
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
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
|
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. Tests are very comprehensive. Excellent job. |
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 |
|---|---|---|
|
|
@@ -7,6 +7,113 @@ test(`Should return 11 when given an ace card`, () => { | |
| expect(getCardValue("A♠")).toEqual(11); | ||
| }); | ||
|
|
||
| describe("Returns numeric value when given cards ranked (2-10)", () => { | ||
| test("Returns 2 when given a card with rank 2", () => { | ||
| expect(getCardValue("2♥")).toEqual(2); | ||
| }); | ||
|
|
||
| test("Returns 3 when given a card with rank 3", () => { | ||
| expect(getCardValue("3♣")).toEqual(3); | ||
| }); | ||
|
|
||
| test("Returns 4 when given a card with rank 4", () => { | ||
| expect(getCardValue("4♦")).toEqual(4); | ||
| }); | ||
|
|
||
| test("Returns 5 when given a card with rank 5", () => { | ||
| expect(getCardValue("5♣")).toEqual(5); | ||
| }); | ||
|
|
||
| test("Returns 6 when given a card with rank 6", () => { | ||
| expect(getCardValue("6♦")).toEqual(6); | ||
| }); | ||
|
|
||
| test("Returns 7 when given a card with rank 7", () => { | ||
| expect(getCardValue("7♠")).toEqual(7); | ||
| }); | ||
|
|
||
| test("Returns 8 when given a card with rank eight", () => { | ||
| expect(getCardValue("8♥")).toEqual(8); | ||
| }); | ||
|
|
||
| test("Returns 9 when given a nine card", () => { | ||
| expect(getCardValue("9♠")).toEqual(9); | ||
| }); | ||
|
|
||
| test("Returns 10 when given a ten card", () => { | ||
| expect(getCardValue("10♣")).toEqual(10); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Returns 10 when given (Q,J or K) cards", () => { | ||
| test("Returns 10 when given a Q card", () => { | ||
| expect(getCardValue("Q♥")).toEqual(10); | ||
| }); | ||
|
|
||
| test("Returns 10 when given a J card", () => { | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| }); | ||
|
|
||
| test("Returns 10 when given a K card", () => { | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Invalid Cards", () => { | ||
| test("Throws an error when given an empty string", () => { | ||
| expect(() => getCardValue("")).toThrow( | ||
| /Expected a valid number followed by a suit, but got ""/ | ||
| ); | ||
| }); | ||
| test("Arbitrary non-card string", () => { | ||
| expect(() => getCardValue("invalid")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "invalid"/ | ||
| ); | ||
|
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. Why test the error message as expect(() => getCardValue("invalid")).toThrow(
/Expected a valid number followed by a suit, but got "invalid"/
);instead of as expect(() => getCardValue("invalid")).toThrow(
'Expected a valid number followed by a suit, but got "invalid"'
);? |
||
| }); | ||
|
|
||
| test("Invalid card rank with no suit", () => { | ||
| expect(() => getCardValue("15")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "15"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("A valid card rank but invalid suit", () => { | ||
| expect(() => getCardValue("8Z")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "8Z"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("A valid suit but invalid card rank", () => { | ||
| expect(() => getCardValue("26♣")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "26♣"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("Rank and suit with an extra letter", () => { | ||
| expect(() => getCardValue("5♣l")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "5♣l"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("Two suits", () => { | ||
| expect(() => getCardValue("♣♠")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "♣♠"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("A negative rank but valid suit", () => { | ||
| expect(() => getCardValue("-4♣")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "-4♣"/ | ||
| ); | ||
| }); | ||
|
|
||
| test("Invalid rank 0 but valid suit", () => { | ||
| expect(() => getCardValue("0♥")).toThrow( | ||
| /Expected a valid number followed by a suit, but got "0♥"/ | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| // Face Cards (J, Q, K) | ||
|
|
@@ -15,4 +122,3 @@ test(`Should return 11 when given an ace 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 | ||
|
|
||
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.
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.
Format (spacing) not fully consistent. Why not use a formatter to keep the code consistently format?