-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
CYF-ITP - South Africa | Simphiwe Mabuya | Structuring-and-Testing-Data | Sprint-3 #215
base: main
Are you sure you want to change the base?
Changes from 99 commits
7c6d5f1
0528968
5ce8556
47d669d
979c099
372d56b
e3732f1
6fb54c4
e3cb721
532476e
621182e
e0ad3e5
b47fbce
16245b5
a96957d
c2f25db
cfe0f8a
fdaf12c
f148ac7
6b0cebf
c307773
5d98686
1bc80f3
23439a6
422e58e
f8b9c01
25826d8
f3e7455
683091e
6d6d37e
3909973
4516ba2
1ca1ee2
2915c06
abb24c9
9af6ad9
54917c6
ff36a57
73fd961
7b7bfd8
d0cc829
5dc6147
205fa03
ca5bb89
22b53a0
a4f4e0f
522a45a
d8a5a24
7500639
c3602a5
76986c6
e6c41c7
9b06ff8
5a5034a
d1ea95f
14cfc68
6f51e96
9bf2414
aab17eb
3d06955
ecd5495
5d467a5
3cc080b
3eabd5f
8b1b59c
0e4fbdd
ffbcb50
8c26e78
f588eac
9d30d13
32c27fb
19784cf
85e30b0
e27cfc2
23bdcf1
a3fc63f
be389fa
811ed1f
59e491e
b5ebdf2
458b348
bd23236
68bd517
7666abf
cc24ffc
5c60e2d
df4c0df
a2e8f9d
cbd8962
86e9340
7e9c514
8f833aa
ee7550e
5374b14
5e10a18
ff75cad
de23baa
d543032
51dc361
049a414
8f51e6a
dc778fe
ff277ba
ed7dee1
3acefb7
a033d20
a3932a4
b6bdcbc
ca55423
8aaa530
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
const getAngleType = require("./get-angle-type"); | ||
|
||
|
||
test("Checks for Right Angle for when the angle is 90 degrees", () => { | ||
expect(getAngleType(90)).toEqual("Right angle"); | ||
}); | ||
|
||
|
||
test("Checks for Acute angle, when the angle < 90 degrees", () => { | ||
expect(getAngleType(45)).toEqual("Acute angle"); | ||
}); | ||
|
||
|
||
test("Checks for Obtuse angle, when the angle > 90 and angle < 180 degrees", () => { | ||
expect(getAngleType(145)).toEqual("Obtuse angle"); | ||
}); | ||
|
||
|
||
test("Checks for Straight angle, when the angle is exactly 180 degrees", () => { | ||
expect(getAngleType(180)).toEqual("Straight angle"); | ||
}); | ||
|
||
|
||
test("Expect 'Reflect angle' when 180 < angle < 360", () => { | ||
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 was just making a suggestion so that you can try to keep the test description concise in the future. 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 the tip CJ ..I thought it was best I used it. |
||
expect(getAngleType(192)).toEqual("Reflex angle"); | ||
}); | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,37 @@ | |
|
||
// You will need to implement a function getCardValue | ||
|
||
function getCardValue(cardRank){ | ||
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.
The card value should always have ONE suite character as the LAST character. So Since there are exactly 13 valid ranks but countless possible invalid ranks, |
||
|
||
if(cardRank === "10"){ | ||
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 can remove the suite character from |
||
return 10; | ||
} | ||
|
||
if(/^0\d/.test(cardRank) || /\.\d/.test(cardRank)){ | ||
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. You can skip checking for possible invalid cases. |
||
return "Invalid card rank"; | ||
} | ||
|
||
cardRank = cardRank.slice(0, 2) === "10" ? "10" : cardRank.slice(0, 1); | ||
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 part should be replaced by a statement that removes the suite character from the string, and should be perform at the beginning of the function. |
||
|
||
if(cardRank ==="A"){ | ||
return 11; | ||
}else if(cardRank === "J" || cardRank === "K" || cardRank === "Q"){ | ||
return 10; | ||
} | ||
|
||
const numericalValue = parseInt(cardRank, 10); | ||
if(numericalValue >= 2 && numericalValue <= 10){ | ||
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. You have already checked for "10" at line 7. So the remaining values to be checked are "2", "3", ..., "9". What do these strings have in common? What condition can you add so that ranks like "2.1" would not pass the check. |
||
return numericalValue; | ||
}else { | ||
return 'Invalid card rank' | ||
} | ||
} | ||
module.exports = getCardValue; | ||
|
||
|
||
//testGetCardValue(); | ||
console.log(getCardValue("2.1♣")); | ||
|
||
// You need to write assertions for your function to check it works in different cases | ||
|
||
// Acceptance criteria: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const getCardValue = require("./get-card-value"); | ||
|
||
|
||
test("Checks if cardRank is 'A♠' then returns 11 ", () => { | ||
expect(getCardValue("A♠")).toEqual(11); | ||
}); | ||
|
||
test("Checks if cardRank is 'J♦' then returns 10 ", () => { | ||
expect(getCardValue("J♦")).toEqual(10); | ||
}); | ||
|
||
test("Checks if cardRank is 'K♥' then returns 10 ", () => { | ||
expect(getCardValue("K♥")).toEqual(10); | ||
}); | ||
|
||
test("Checks if cardRank is 'Q♣' then returns 10 ", () => { | ||
expect(getCardValue("Q♣")).toEqual(10); | ||
}); | ||
|
||
test("Checks if cardRank is '8' then returns 8 ", () => { | ||
expect(getCardValue("8")).toEqual(8); | ||
}); | ||
|
||
test("Checks if cardRank is '2.1' then returns 'Invalid card rank", () => { | ||
expect(getCardValue("2.1♣")).toEqual("Invalid card rank"); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const isProperFraction = require("./is-proper-fraction"); | ||
|
||
|
||
test("Checks if the fraction is a Proper fraction (2/3) or (-4/-7) then return true", () => { | ||
expect(isProperFraction(1, 2)).toEqual(true); | ||
expect(isProperFraction(-4,-7)).toEqual(true); | ||
}); | ||
|
||
test("Checks if the fraction is a Negative fraction (-4/7) then return true", () => { | ||
expect(isProperFraction(-4, 7)).toEqual(true); | ||
}); | ||
|
||
test("Checks if the fraction is an Improper fraction (5/3) then return false", () => { | ||
expect(isProperFraction(5, 3)).toEqual(false); | ||
}); | ||
|
||
test("Checks if the Numerator === Denominator (3/3) then return false", () => { | ||
expect(isProperFraction(3, 3)).toEqual(false); | ||
}); | ||
|
||
test("Throws an error when the denominator is zero", () => { | ||
expect(() => isProperFraction(3, 0)).toThrow("Denominator must be a positive or negative number"); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const isValidTriangle = require("./is-valid-triangle"); | ||
|
||
test("Checks for Valid Triangle where the sum is (a + b > c)", () => { | ||
expect(isValidTriangle(3, 5, 4)).toEqual(true); | ||
}); | ||
|
||
test("Checks for Invalid Triangle when any of the sides are less than or equal to zero ", () => { | ||
expect(isValidTriangle(0, 2, 4)).toEqual(false); | ||
}); | ||
|
||
test("Checks for Invalid Triangle, where the sum is (b + c <= a)", () => { | ||
expect(isValidTriangle(2, 2, 4)).toEqual(false); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const rotateCharacter = require("./rotate-character"); | ||
|
||
test("Checks for Rotate Lowercase Letters", () => { | ||
expect(rotateCharacter("a", 3)).toEqual("d"); | ||
}); | ||
|
||
test("Checks for Rotate Uppercase Letters", () => { | ||
expect(rotateCharacter("F", 1)).toEqual("G"); | ||
}); | ||
|
||
test("Checks for where Non-Letter Characters are left Unchanged", () => { | ||
expect(rotateCharacter(7, 5)).toEqual(7); | ||
}); | ||
|
||
test("Checks if a Characters shift with Wraparound", () => { | ||
expect(rotateCharacter("Y", 2)).toEqual("A"); | ||
}); | ||
|
||
|
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.
What do you expect
getAngleType(-5)
to return?