-
-
Notifications
You must be signed in to change notification settings - Fork 386
London | 26-ITP-May | Yonatan Teklemariam | Sprint 3 | Implement and re-write tests #1381
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
Yonatanteklemariam
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
Yonatanteklemariam: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.
+212
−7
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ef19ec
written tests to check whether a given angle matches the expected output
Yonatanteklemariam df94ea4
written jest test scripts for all the three functions
Yonatanteklemariam baa070c
written jest tests for all the three functions and tests returned as …
Yonatanteklemariam 7bcf484
removed the redundant and unreachable codes
Yonatanteklemariam a0be617
fix: revert files to orginal
Yonatanteklemariam 8a5a9f0
fix; revert to original
Yonatanteklemariam 033144b
Refactor isProperFraction to remove zero numerator check
Yonatanteklemariam 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 |
|---|---|---|
|
|
@@ -4,7 +4,40 @@ 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 | ||
| // Special case: denominator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| //Special case: numerator is zero | ||
| test(`should return false when numerator is zero`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(false); | ||
| }); | ||
| // Proper functions with absolute numerator < absolute denominator | ||
| test(`should return true for proper positive fractions`, () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| expect(isProperFraction(3, 4)).toEqual(true); | ||
| }); | ||
| // Proper functions with negative numbers | ||
| test(`should return true for proper negative fractions`, () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| expect(isProperFraction(1, -3)).toEqual(true); | ||
| expect(isProperFraction(-2, -5)).toEqual(true); | ||
| }); | ||
| // Improper functions with absolute numerator >= absolute denominator | ||
| test(`should return false for improper fractions`, () => { | ||
| expect(isProperFraction(5, 3)).toEqual(false); | ||
| expect(isProperFraction(10, 10)).toEqual(false); | ||
| expect(isProperFraction(-7, 3)).toEqual(false); | ||
| }); | ||
| // Special cases: numerator or denominator is NAN | ||
| test(`should return false when numerator or denominator is NaN`, () => { | ||
| expect(isProperFraction(NaN, 5)).toEqual(false); | ||
| expect(isProperFraction(3, NaN)).toEqual(false); | ||
| expect(isProperFraction(NaN, NaN)).toEqual(false); | ||
| }); | ||
| // Special cases: non-number strings | ||
| test(`should return false for non-numeric strings`, () => { | ||
| expect(isProperFraction("a", 5)).toEqual(false); | ||
| expect(isProperFraction(3, "b")).toEqual(false); | ||
| }); | ||
|
Comment on lines
+39
to
+43
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. What do you mean by "non-numeric strings"? Is "3e2" a non-numeric string? |
||
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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| function repeatStr() { | ||
| function repeatStr(str, count) { | ||
| // Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat). | ||
| // The goal is to re-implement that function, not to use it. | ||
| return "hellohellohello"; | ||
| return str.repeat(count); | ||
| } | ||
|
|
||
| module.exports = repeatStr; |
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.