-
-
Notifications
You must be signed in to change notification settings - Fork 337
London | 25-ITP-Sep | Payman Issa Baiglu | sprint 3 | 1- implement-and-rewrite #890
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
Changes from 1 commit
66afa7c
4c6389a
366b81a
624db1f
15f5661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,22 @@ test("should return true for a proper fraction", () => { | |
| }); | ||
|
|
||
| // Case 2: Identify Improper Fractions: | ||
| test("should return false for an improper fraction", () =>{ | ||
| expect(isProperFraction(5, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| // Case 3: Identify Negative Fractions: | ||
| test("should return true for negative proper fraction", () => ( | ||
| expect(isProperFraction(-4,7)).toEqual(true) | ||
| )); | ||
|
|
||
| // Case 4: Identify Equal Numerator and Denominator: | ||
| test("should return false when numerator equals denominator", () => { | ||
| expect(isProperFraction(3,3)).toEqual(false); | ||
| }); | ||
|
|
||
| // Stretch: | ||
| // What other scenarios could you test for? | ||
| test("should return true for negative proper fraction with negative denominator", () => { | ||
| expect(isProperFraction(4,-7)).toEqual(true); | ||
| }); | ||
|
Comment on lines
+10
to
+28
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 are your expected range of numerators and denominators? If you test all possible combinations of positive/negative
Author
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. Thanks for pointing that out. Yes in some other calculations the output will be undefined. I fixed the function.
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. We could make the test more comprehensive by testing all combination of negative and positive parameters.
Author
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. Thanks for clarifying this with an example. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // This statement loads the getCardValue function you wrote in the implement directory. | ||
| // We will use the same function, but write tests for it using Jest in this file. | ||
| // const { test } = require("picomatch"); | ||
| const getCardValue = require("../implement/3-get-card-value"); | ||
|
|
||
| test("should return 11 for Ace of Spades", () => { | ||
|
|
@@ -8,6 +9,27 @@ test("should return 11 for Ace of Spades", () => { | |
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return numeric value for number cards (2-10)", () => { | ||
| const fiveofHearts = getCardValue("5♥"); | ||
| expect(fiveofHearts).toEqual(5); | ||
| }); | ||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for face cards (J, Q, K) and 10", () => { | ||
| expect(getCardValue("10♦")).toEqual(10); | ||
|
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.
Author
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. CAn you please explain more. So, you mean that I should write a test for 2 as well?
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. In your test category for number cards, you only tested one rank, "5".
Author
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. Thanks for clarifying this. I tried to do both. so first I wrote tests for boundary (2 & 10) which are commented now.. and then wrote a test to cover all numbers. |
||
| expect(getCardValue("J♣")).toEqual(10); | ||
| expect(getCardValue("Q♥")).toEqual(10); | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| }); | ||
| // Case 4: Handle Ace (A): | ||
| test("should return 11 for Ace (A)", () => { | ||
| expect(getCardValue("A♦")).toEqual(11); | ||
| }); | ||
|
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. This test and the test on lines 7-9 are quite similar.
Author
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. Noted, Thank you. I removed this one. |
||
| // Case 5: Handle Invalid Cards: | ||
| test("should throw an error for invalid card rank", () => { | ||
| expect(() => { | ||
| getCardValue("1♠"); | ||
| }).toThrow("Invalid card rank."); | ||
| expect(() => { | ||
| getCardValue("B♥"); | ||
| }).toThrow("Invalid card rank."); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <coverage generated="1763210812403" clover="3.2.0"> | ||
| <project timestamp="1763210812404" name="All files"> | ||
| <metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/> | ||
| </project> | ||
| </coverage> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
Uh oh!
There was an error while loading. Please reload this page.