-
-
Notifications
You must be signed in to change notification settings - Fork 259
Glasgow | 25-ITP-Sep | Fares Bakhet | Sprint 3 | coursework/sprint-3-implement-and-rewrite #755
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 9 commits
8738ad1
ed40750
e6d384c
a2b2e06
11efcb1
d440aaf
07685f8
283fe06
7139e24
29b1e29
4c6b2b2
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 |
|---|---|---|
| @@ -1,13 +1,22 @@ | ||
| // 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"); | ||
| const isProperFraction = require("../implement/2-is-proper-fraction"); // The path | ||
|
|
||
| test("should return true for a proper fraction", () => { | ||
| expect(isProperFraction(2, 3)).toEqual(true); | ||
| }); | ||
|
|
||
| // Case 2: Identify Improper Fractions: | ||
| test("should return false for an improper fraction", () => { | ||
| expect(isProperFraction(5, 4)).toEqual(false); | ||
| }); | ||
|
|
||
| // Case 3: Identify Negative Fractions: | ||
| test("should return true for a negative fraction", () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| }); | ||
|
|
||
| // Case 4: Identify Equal Numerator and Denominator: | ||
| test("should return false for equal numerator and denominator", () => { | ||
| expect(isProperFraction(3, 3)).toEqual(false); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,29 @@ test("should return 11 for Ace of Spades", () => { | |
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return 5 for Five of Hearts", () => { | ||
| const fiveofHearts = getCardValue("5♥"); | ||
| expect(fiveofHearts).toEqual(5); | ||
| }); | ||
|
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for all face cards (J, Q, K)", () => { | ||
| const faceCards = ["J♦", "Q♣", "K♥"]; | ||
| faceCards.forEach((card) => { | ||
| const value = getCardValue(card); | ||
| expect(value).toEqual(10); | ||
| }); | ||
| }); | ||
| // Case 4: Handle Ace (A): | ||
| test("should return 11 for Ace of Spades", () => { | ||
| const aceofSpades = getCardValue("A♠"); | ||
| expect(aceofSpades).toEqual(11); | ||
| }); | ||
| // Case 5: Handle Invalid Cards: | ||
| test("should return Invalid card rank for an invalid card rank", () => { | ||
| const invalidCard = getCardValue("1♣"); | ||
| expect(invalidCard).toEqual("Invalid card rank"); | ||
| }); | ||
| test("should return Invalid card rank for another invalid card rank", () => { | ||
| const anotherInvalidCard = getCardValue("B♦"); | ||
| expect(anotherInvalidCard).toEqual("Invalid card rank"); | ||
| }); | ||
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.
Can you find all places where you can remove redundant checks and update the code accordingly?
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.
@cjyuan, okay.
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.
@cjyuan,
If I want to rearrange this again, I will end up in this way:
Right??
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.
I can't tell.
180 & < 360is not exactly JS code.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.
@cjyuan,
I was shortcutting
if( angle > 180 && angle <360)
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.
I still don't know wat you try to expressed:

I suspect part of the code is misinterpreted as Markdown code. Here is the GitHub Markdown guide:
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax