generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 337
London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Implement And Rewrite Tests #1045
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
XiaoQuark
wants to merge
10
commits into
CodeYourFuture:main
Choose a base branch
from
XiaoQuark:coursework/sprint-3
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.
+334
−8
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5a0dfa0
write getAngleType function and assert tests
XiaoQuark f5555b2
write jest tests for getAngleType function
XiaoQuark c852657
write a series of tests for isProperFraction() function
XiaoQuark ad52844
rewrite all tests based on mathematical definition of proper fractions
XiaoQuark 8a750dd
write function is ProperFraction() to pass all tests
XiaoQuark 9fd83a0
refactor first test, splitting it into two, for more explicit testing…
XiaoQuark 9cc4680
write tests for function getCardValue
XiaoQuark e2a6053
write getCardValue() function ensuring all tests pass
XiaoQuark 8adf134
refactor code for more descriptive error messages
XiaoQuark faa279a
refactor: change let variables to const and add early validation for …
XiaoQuark 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,45 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
| // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. | ||
|
|
||
| // Special case: numerator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
|
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. Is there a reason why this test was deleted? |
||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
|
|
||
| test(`should return true when the absolute value of the numerator is less than the absolute value of the denominator and the denominator is not 0`, () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| expect(isProperFraction(1, -3)).toEqual(true); | ||
| expect(isProperFraction(3.5, 4)).toEqual(true); | ||
| expect(isProperFraction(-99, -100)).toEqual(true); | ||
| expect(isProperFraction(8, 12.5)).toEqual(true); | ||
| expect(isProperFraction(-6, 12)).toEqual(true); | ||
| expect(isProperFraction(0.03, 0.1)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return true when numerator is equal to 0 and denominator is either positive or negative`, () => { | ||
| expect(isProperFraction(0, -5)).toEqual(true); | ||
| expect(isProperFraction(0, 56)).toEqual(true); | ||
| expect(isProperFraction(0, 0.1)).toEqual(true); | ||
| expect(isProperFraction(0, -8.9)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return false when the denominator is equal to zero`, () => { | ||
| expect(isProperFraction(-1, 0)).toEqual(false); | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| expect(isProperFraction(15, 0)).toEqual(false); | ||
| expect(isProperFraction(6.4, 0)).toEqual(false); | ||
| expect(isProperFraction(-8.5, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when the absolute value of the numerator is greater than the absolute value of the denominator`, () => { | ||
| expect(isProperFraction(3, 2)).toEqual(false); | ||
| expect(isProperFraction(-9, 3)).toEqual(false); | ||
| expect(isProperFraction(-15, -4)).toEqual(false); | ||
| expect(isProperFraction(36, -5)).toEqual(false); | ||
| expect(isProperFraction(3.8, 2.7)).toEqual(false); | ||
| expect(isProperFraction(1, 0.7)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when the absolute value of the numerator is equal to the absolute value of the denominator`, () => { | ||
| expect(isProperFraction(3, 3)).toEqual(false); | ||
| expect(isProperFraction(-19, -19)).toEqual(false); | ||
| expect(isProperFraction(7.45, 7.45)).toEqual(false); | ||
| expect(isProperFraction(67, -67)).toEqual(false); | ||
| expect(isProperFraction(-8, 8)).toEqual(false); | ||
| }); | ||
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.
This is a nice improvement,
For the numeric cards, do you think you could check if the rank is between 1 and 10 instead of listing each value from 1 to 10? For example, by converting cardRank to a number and checking something like >= 1 && <= 10.