Skip to content

Commit 47fad65

Browse files
committed
Adjusments made on rewriting tests with Jest for the getAngleType function. Added an example test case for right angles and a comment to indicate where to write additional tests. Also added explanations for the implementation of the isProperFraction function and the multiply function in the previous sprint.
1 parent c9ae221 commit 47fad65

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
// This statement loads the getAngleType function you wrote in the implement directory.
22
// We will use the same function, but write tests for it using Jest in this file.
33
const getAngleType = require("../implement/1-get-angle-type");
4+
//
45

56
// TODO: Write tests in Jest syntax to cover all cases/outcomes,
67
// including boundary and invalid cases.
8+
// Example: Identify Right Angles
9+
test(`should return "Right angle" when angle is 90`, () => {
10+
expect(getAngleType(90)).toEqual("Right angle");
11+
});
12+
713

814
// Case 1: Acute angles
915
test(`should return "Acute angle" when (0 < angle < 90)`, () => {
@@ -18,3 +24,4 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
1824
// Case 4: Straight angle
1925
// Case 5: Reflex angles
2026
// Case 6: Invalid angles
27+

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,42 @@
33
const isProperFraction = require("../implement/2-is-proper-fraction");
44

55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
6+
// Example: 1/2 is a proper fraction
7+
test(`should return true for 1/2`, () => {
8+
expect(isProperFraction(1, 2)).toEqual(true);
9+
});
10+
// Example: 2/1 is not a proper fraction
11+
test(`should return false for 2/1`, () => {
12+
expect(isProperFraction(2, 1)).toEqual(false);
13+
});
14+
// Example: -1/2 is a proper fraction
15+
test(`should return true for -1/2`, () => {
16+
expect(isProperFraction(-1, 2)).toEqual(true);
17+
});
18+
// Example: 1/-2 is a proper fraction
19+
test(`should return true for 1/-2`, () => {
20+
expect(isProperFraction(1, -2)).toEqual(true);
21+
});
22+
// Example: -1/-2 is a proper fraction
23+
test(`should return true for -1/-2`, () => {
24+
expect(isProperFraction(-1, -2)).toEqual(true);
25+
});
26+
// Example: 0/5 is a proper fraction
27+
test(`should return true for 0/5`, () => {
28+
expect(isProperFraction(0, 5)).toEqual(true);
29+
});
30+
// Example: 5/0 is not a proper fraction
31+
test(`should return false for 5/0`, () => {
32+
expect(isProperFraction(5, 0)).toEqual(false);
33+
});
34+
// Example: 5/5 is not a proper fraction
35+
test(`should return false for 5/5`, () => {
36+
expect(isProperFraction(5, 5)).toEqual(false);
37+
});
38+
// Special case: numerator is zero
39+
test(`should return false when denominator is zero`, () => {
40+
expect(isProperFraction(1, 0)).toEqual(false);
41+
});
642

743
// Special case: numerator is zero
844
test(`should return false when denominator is zero`, () => {

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
const getCardValue = require("../implement/3-get-card-value");
44

55
// TODO: Write tests in Jest syntax to cover all possible outcomes.
6+
// Examples:
7+
test(`should return 9 for "9♠"`, () => {
8+
expect(getCardValue("9♠")).toEqual(9);
9+
});
10+
11+
test(`should return 11 for "A♥"`, () => {
12+
expect(getCardValue("A♥")).toEqual(11);
13+
});
14+
15+
test(`should return 10 for "J♦"`, () => {
16+
expect(getCardValue("J♦")).toEqual(10);
17+
});
18+
19+
test(`should return 10 for "Q♣"`, () => {
20+
expect(getCardValue("Q♣")).toEqual(10);
21+
});
22+
23+
test(`should return 10 for "K♠"`, () => {
24+
expect(getCardValue("K♠")).toEqual(10);
25+
});
26+
627

728
// Case 1: Ace (A)
829
test(`Should return 11 when given an ace card`, () => {
@@ -14,6 +35,7 @@ test(`Should return 11 when given an ace card`, () => {
1435
// Face Cards (J, Q, K)
1536
// Invalid Cards
1637

38+
1739
// To learn how to test whether a function throws an error as expected in Jest,
1840
// please refer to the Jest documentation:
1941
// https://jestjs.io/docs/expect#tothrowerror

0 commit comments

Comments
 (0)