generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 239
London | 25-ITP-Sep | Shaghayegh Shirinfar | Sprint 3 | Implement-and-rewrite-tests #817
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
shaghayeghfar
wants to merge
3
commits into
CodeYourFuture:main
Choose a base branch
from
shaghayeghfar:coursework/sprint-3-implement-and-rewrite2
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
3 commits
Select commit
Hold shift + click to select a range
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
38 changes: 22 additions & 16 deletions
38
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
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,26 +1,32 @@ | ||
| // This statement loads the getAngleType function you wrote in the implement directory. | ||
| // We will use the same function, but write tests for it using Jest in this file. | ||
| const getAngleType = require("../implement/1-get-angle-type"); | ||
|
|
||
| // Case 1: Identify Right Angles | ||
| test("should identify right angle (90°)", () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| }); | ||
|
|
||
| // REPLACE the comments with the tests | ||
| // make your test descriptions as clear and readable as possible | ||
|
|
||
| // Case 2: Identify Acute Angles: | ||
| // When the angle is less than 90 degrees, | ||
| // Then the function should return "Acute angle" | ||
| // Case 2: Identify Acute Angles | ||
| // | ||
| // When the angle is less than 90 degrees, it should return "Acute angle" | ||
| test("should identify acute angle (<90°)", () => { | ||
| expect(getAngleType(45)).toEqual("Acute angle"); | ||
| }); | ||
|
|
||
| // Case 3: Identify Obtuse Angles: | ||
| // When the angle is greater than 90 degrees and less than 180 degrees, | ||
| // Then the function should return "Obtuse angle" | ||
| // Case 3: Identify Obtuse Angles | ||
| // When the angle is greater than 90 degrees and less than 180 degrees, it should return "Obtuse angle" | ||
| test("should identify obtuse angle (>90° and <180°)", () => { | ||
| expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Identify Straight Angles: | ||
| // When the angle is exactly 180 degrees, | ||
| // Then the function should return "Straight angle" | ||
| // Case 4: Identify Straight Angles | ||
| // When the angle is exactly 180 degrees, it should return "Straight angle" | ||
| test("should identify straight angle (180°)", () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Identify Reflex Angles: | ||
| // When the angle is greater than 180 degrees and less than 360 degrees, | ||
| // Then the function should return "Reflex angle" | ||
| // Case 5: Identify Reflex Angles | ||
| // When the angle is greater than 180 degrees and less than 360 degrees, it should return "Reflex angle" | ||
| test("should identify reflex angle (>180° and <360°)", () => { | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| }); |
53 changes: 47 additions & 6 deletions
53
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
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,13 +1,54 @@ | ||
| // This statement loads the isProperFraction function you wrote in the implement directory. | ||
| // We will use the same function, but write tests for it using Jest in this file. | ||
| const isProperFraction = require("../implement/2-is-proper-fraction"); | ||
|
|
||
| test("should return true for a proper fraction", () => { | ||
| // Case 1: Proper fraction | ||
| test("should return true for a proper fraction (numerator < denominator)", () => { | ||
| expect(isProperFraction(2, 3)).toEqual(true); | ||
| }); | ||
| // | ||
|
|
||
| // Case 2: Identify Improper Fractions: | ||
| // Case 2: Improper fraction | ||
| test("should return false for an improper fraction (numerator > denominator)", () => { | ||
| expect(isProperFraction(5, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| // // Case 3: Negative fraction | ||
| // test("should return true for a negative proper fraction (numerator < denominator)", () => { | ||
| // expect(isProperFraction(-4, 7)).toEqual(true); | ||
| // }); | ||
|
|
||
| // Case 4: Numerator equal to denominator | ||
| test("should return false when numerator equals denominator", () => { | ||
| expect(isProperFraction(3, 3)).toEqual(false); | ||
| }); | ||
|
|
||
| // Optional: Zero numerator | ||
| test("should return true when numerator is zero", () => { | ||
| expect(isProperFraction(0, 5)).toEqual(true); | ||
| }); | ||
|
|
||
| // // Case 5: Negative denominator | ||
| // test("should return true when denominator is negative and proper", () => { | ||
| // expect(isProperFraction(2, -5)).toEqual(true); | ||
| // }); | ||
|
|
||
| //handle all negative number scenarios | ||
|
|
||
| // Case 3: Identify Negative Fractions: | ||
| test("should correctly handle all negative number scenarios", () => { | ||
| const cases = [ | ||
| // Proper negatives (absolute numerator < absolute denominator) | ||
| [-4, 7, true, "-4/7 proper fraction"], | ||
| [4, -7, true, "4/-7 proper fraction"], | ||
| [-2, -5, true, "-2/-5 proper fraction"], | ||
|
|
||
| // Case 4: Identify Equal Numerator and Denominator: | ||
| // Improper negatives (absolute numerator >= absolute denominator) | ||
| [-5, 2, false, "-5/2 improper fraction"], | ||
| [5, -2, false, "5/-2 improper fraction"], | ||
| [-7, -4, false, "-7/-4 improper fraction"], | ||
|
|
||
| // Edge equal case | ||
| [-3, -3, false, "-3/-3 equal fraction"], | ||
| ]; | ||
|
Comment on lines
+48
to
+50
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. Could also consider checking -3/3 and 3/-3. |
||
| for (const [num, den, expected, desc] of cases) { | ||
| expect(isProperFraction(num, den)).toBe(expected); | ||
| } | ||
| }); | ||
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
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.
Code submitted to a PR should be free of any unused code. Keeping code clean makes code easier to review.
Should you ever need this code in the future, you can recover or access the code from previous commits. Whenever we make a commit, Git "save a copy of the whole repository" when the commit was made.