-
-
Notifications
You must be signed in to change notification settings - Fork 240
West Midlands | MAY | EMIN AKTURK | Sprint 3 | MODULE-STRUCTURING-AND-TESTING-DATA #692
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 23 commits
84e3bca
3c9fb3a
c882576
8ccf3b2
d0c0bd7
721fe57
3eff2ca
0de42f1
5d8d05c
7fe2790
fed3a0c
16e88b9
17f9a99
4266d77
05564df
a932cb1
2c47ed9
1b7c8c7
c95381e
1fd0b02
71b7003
0c7b105
97d27ed
47d5d46
2f97455
29d0ece
315d99a
d31e82f
cf78bda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
|
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. If you run this file to see if your tests pass, what happens? I get an error related to the fyi: You can test the file by opening your terminal (making sure you are in the Sprint-3/1-key-implement directory) and typing: |
|
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. There may be a few edge cases missed here.
|
|
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. I think you may be missing a few edge cases in your getAngleType function.
|
|
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. Did you run the tests in this file? I get an error when I do, can you find it and fix it? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| function isProperFraction(numerator, denominator) { | ||
| if (numerator < denominator) return true; | ||
| // add your completed function from key-implement here | ||
| if (Math.abs(numerator) < Math.abs(denominator)) { | ||
| return true; | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| module.exports = isProperFraction; | ||
| module.exports = isProperFraction; |
|
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 about this test? A fraction with a zero denominator is considered an invalid fraction. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| function getCardValue(card) { | ||
| // replace with your code from key-implement | ||
| return 11; | ||
| const rank = card.slice(0, -1); | ||
| if (rank === "A") return 11; | ||
| if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10; | ||
| if (!isNaN(rank)) return Number(rank); | ||
| throw new Error("Invalid card rank."); | ||
| } | ||
| module.exports = getCardValue; | ||
|
|
||
| module.exports = getCardValue; |
|
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. I suggest adding tests for these edge cases:
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,26 @@ const getCardValue = require("./3-get-card-value"); | |
| test("should return 11 for Ace of Spades", () => { | ||
| const aceofSpades = getCardValue("A♠"); | ||
| expect(aceofSpades).toEqual(11); | ||
| }); | ||
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return correct number for number cards", () => { | ||
| expect(getCardValue("5♥")).toEqual(5); | ||
| expect(getCardValue("10♦")).toEqual(10); | ||
| }); | ||
|
|
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for face cards J, Q, K", () => { | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| expect(getCardValue("Q♦")).toEqual(10); | ||
| expect(getCardValue("K♥")).toEqual(10); | ||
| }); | ||
|
|
||
| // Case 4: Handle Ace (A): | ||
| // (Already tested above with Ace of Spades) | ||
|
|
||
| // Case 5: Handle Invalid Cards: | ||
| test("should throw error for invalid cards", () => { | ||
|
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 review the test at line 25? The assertion fails. |
||
| expect(() => getCardValue("Z♠")).toThrow("Invalid card rank."); | ||
| expect(() => getCardValue("1♠")).toThrow("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.
I think you may be missing a few edge cases in your getAngleType function.
const nothing = getAngleType();const tooBig = getAngleType(361);