Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e8606f9
Work on "Right angle"
HM-127BTY Oct 7, 2026
53621cd
Added tests for all the angles, next working on code
HM-127BTY Oct 7, 2026
5721c8b
Added code for Acute angle
HM-127BTY Oct 7, 2026
5e692d8
Added code for Obtuse angle
HM-127BTY Oct 7, 2026
b61b4b4
Added code for Straight angle
HM-127BTY Oct 7, 2026
7ccf911
Added code for Reflex angles
HM-127BTY Oct 7, 2026
426aabb
Added code for Invalid angle
HM-127BTY Oct 7, 2026
1c3277f
fixed errors and rearranged code to be easier to read
HM-127BTY Oct 8, 2026
c4786d8
Set up testing requirements for the fractions
HM-127BTY Oct 8, 2026
707ac48
Done the code for fractions coving test requests.
HM-127BTY Oct 8, 2026
16f4f20
cleaned up the code
HM-127BTY Oct 8, 2026
e3a8f17
added basic tests needed and non - card string.
HM-127BTY Oct 8, 2026
ae7ef77
working on code and trying to fix errors
HM-127BTY Oct 8, 2026
d4db679
finished code and tests for 3 types:
HM-127BTY Oct 8, 2026
9970ef6
cleaned up errors i encountered .
HM-127BTY Oct 8, 2026
2830bf3
Added in test for Right angle.
HM-127BTY Oct 9, 2026
c7af1dd
Added test for Obtuse angles
HM-127BTY Oct 9, 2026
2fc4cd2
Added test for Straight angles
HM-127BTY Oct 9, 2026
8662c14
Added tests for Right angles
HM-127BTY Oct 9, 2026
6ae03b0
Added tests for Invalid angles
HM-127BTY Oct 9, 2026
3727932
Added in commented tests to update as I progress though tests.
HM-127BTY Oct 9, 2026
5d6c6ef
Added code for Improper fraction: Numerator = Denominator
HM-127BTY Oct 9, 2026
b155253
Added code for Improper fraction: Numerator > Denominator
HM-127BTY Oct 9, 2026
6f64f2e
Added code for -Numerator > Denominator
HM-127BTY Oct 9, 2026
b37a765
Setup code for more tests.
HM-127BTY Oct 9, 2026
9770764
Added code for return 10 for J, Q, K.
HM-127BTY Oct 9, 2026
67f4dd7
Added code for throw error invalid card
HM-127BTY Oct 9, 2026
77cf05b
Added in testing code for Incorrect Suit and fixed errors with lackin…
HM-127BTY Oct 9, 2026
3f42554
fixing erros in code and including "Incorrect card number" test
HM-127BTY Oct 9, 2026
328f3c1
fixed errors and put in more test code for Incorrect card given
HM-127BTY Oct 9, 2026
0cca1dc
Added code and test for Full and Zero Angle.
HM-127BTY Oct 10, 2026
2633baa
Added jest tests for Zero and Full angles
HM-127BTY Oct 10, 2026
9cf8fc2
Added in extra invalid for negative number and fixed errors for full …
HM-127BTY Oct 10, 2026
876923e
Added more negative number tests and additional improper fractions fo…
HM-127BTY Oct 10, 2026
899e435
Changed zero and full angles to Invalid angles
HM-127BTY Oct 12, 2026
248c2e8
changed last "else if" to "else"
HM-127BTY Oct 12, 2026
e6b8b53
Added tests for 0 with negative denominator or numerator
HM-127BTY Oct 12, 2026
23c6ee7
made change to include any value under 1 to be Incorrect card number …
HM-127BTY Oct 13, 2026
1236e2f
Added in a if for Number.isNaN to check if for word or symbol input i…
HM-127BTY Oct 13, 2026
0845379
Added tests for invalid values
HM-127BTY Oct 13, 2026
0569019
Added extra jest tests for incorrect card given.
HM-127BTY Oct 13, 2026
1a20c17
fixed bug with having two tests doing - numerators.
HM-127BTY Oct 13, 2026
ba66435
added both as negative test
HM-127BTY Oct 13, 2026
cdd5f00
Added test for both being 0
HM-127BTY Oct 14, 2026
8b09c49
Added tests missing from requests
HM-127BTY Oct 14, 2026
f78ab0d
Fixed spelling error in thrown error.
HM-127BTY Oct 14, 2026
7046cb7
Found bug in all toThrow tests, had toThrow; so was getting false pos…
HM-127BTY Oct 14, 2026
57ae03a
Organized order of tests to be easier to follow, added extra tests to…
HM-127BTY Oct 16, 2026
9154abe
Added tests for:
HM-127BTY Oct 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,40 @@ test("Classifies right angles", () => {
const right = getAngleType(90);
assert.equal(right, "Right angle");
});
// "Acute angle" for angles greater than 0° and less than 90°
test("Classifies Acute angles", () => {
const right = getAngleType(45);
assert.equal(right, "Acute angle");
});
// - "Obtuse angle" for angles greater than 90° and less than 180°
test("Classifies Obtuse angles", () => {
const right = getAngleType(135);
assert.equal(right, "Obtuse angle");
});
// - "Straight angle" for exactly 180°
test("Classifies Straight angles", () => {
const right = getAngleType(180);
assert.equal(right, "Straight angle");
});
// - "Reflex angle" for angles greater than 180° and less than 360°
test("Classifies Reflex angles", () => {
const right = getAngleType(225);
assert.equal(right, "Reflex angle");
});
// - "Invalid angle" for angles outside the valid range.
test("Classifies Invalid angles", () => {
const right = getAngleType(361);
assert.equal(right, "Invalid angle");
const right = getAngleType(-361);
assert.equal(right, "Invalid angle");
});
// - "Invalid angle" for angles that are at 0°
test("Classifies Invalid angles for 0", () => {
const right = getAngleType(0);
assert.equal(right, "Invalid angle");
});
// - "Invalid angle" for angles that are at 360°
test("Classifies Invalid angles for 360", () => {
const right = getAngleType(360);
assert.equal(right, "Invalid angle");
});
Comment on lines +33 to +39

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be one more boundary case for invalid angle. Can you think of it? Please add it back. Thank you.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added invalid angle for negative numbers.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,71 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
// TODO: Write tests to cover all cases.
// What combinations of numerators and denominators should you test?

test("Basic proper fraction", () => {
test("Basic proper fraction: Numerator < Denominator", () => {
// Example: 1/2 is a proper fraction
assert.equal(isProperFraction(1, 2), true);
});

test("Proper fraction with negative number: -Numerator < Denominator", () => {
assert.equal(isProperFraction(-1, 2), true);
});

test("Proper fraction with negative number: Numerator < -Denominator", () => {
assert.equal(isProperFraction(1, -2), true);
});

test("Proper fraction with negative numbers: -Numerator < -Denominator", () => {
assert.equal(isProperFraction(-1, -2), true);
});

test("Improper fraction: Numerator = Denominator", () => {
assert.equal(isProperFraction(2, 2), false);
});

test("Improper fraction with same value and negative number: -Numerator > Denominator", () => {
assert.equal(isProperFraction(-2, 2), false);
});

test("Improper fraction with same value and negative number: Numerator > -Denominator", () => {
assert.equal(isProperFraction(2, -2), false);
});

test("Improper fraction same value and both negative: Numerator = Denominator", () => {
assert.equal(isProperFraction(-2, -2), false);
});

test("improper fraction: Numerator > Denominator", () => {
assert.equal(isProperFraction(2, 1), false);
});

test("Improper fraction with negative number: -Numerator > Denominator", () => {
assert.equal(isProperFraction(-2, 1), false);
});

test("Improper fraction with negative number: Numerator > -Denominator", () => {
assert.equal(isProperFraction(2, -1), false);
});

test("Improper fraction with negative numbers: -Numerator > -Denominator", () => {
assert.equal(isProperFraction(-2, -1), false);
});

test("Improper fraction: Denominator = 0", () => {
assert.equal(isProperFraction(1, 0), false);
});

test("Proper fraction with negative Numerator and Zero: -Numerator < 0", () => {
assert.equal(isProperFraction(-1, 0), false);
});

test("Improper fraction: Nominator = 0", () => {
assert.equal(isProperFraction(0, 2), false);
});

test("Proper fraction with Zero and negative Denominator: 0 < -Denominator", () => {
assert.equal(isProperFraction(0, -2), false);
});

test("Proper fraction with both being Zero", () => {
assert.equal(isProperFraction(0, 0), false);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both valid and invalid cards, there should be more test cases covering various combinations. Please add them. Thank you.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,79 @@ test("Valid single-digit card", () => {
});

test("Arbitrary non-card string", () => {
assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error");
assert.throws(
() => getCardValue("invalid"),
/Expected a number followed by a suit, but got "invalid"/,
"Expected clear error"
);
});

// TODO: What other invalid card cases can you think of?
//Incorrect suit as symbol
test("Incorrect suit", () => {
assert.throws(
() => getCardValue("2☺"),
/Incorrect suit given/,
"Incorrect suit"
);
});

//Incorrect suit as letter
test("Incorrect suit", () => {
assert.throws(
() => getCardValue("7l"),
/Incorrect suit given/,
"Incorrect suit"
);
});

//Incorrect card value to high
test("Incorrect card number: High value", () => {
assert.throws(
() => getCardValue("20♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});
//Incorrect card value when negative
test("Incorrect card number: Negative Number", () => {
assert.throws(
() => getCardValue("-2♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});
//Incorrect card value when symbol
test("Incorrect card number: Symbol", () => {
assert.throws(
() => getCardValue("🐱♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});
//Incorrect card value when letter
test("Incorrect card number: Letter", () => {
assert.throws(
() => getCardValue("H♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});

//Incorrect card value when lower case Royal
test("Incorrect card number: lower case Royal", () => {
assert.throws(
() => getCardValue("k♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});

//Incorrect card value when lower case Ace
test("Incorrect card number: lower case Ace", () => {
assert.throws(
() => getCardValue("a♦"),
/Incorrect card number given/,
"Incorrect card number given"
);
});
17 changes: 17 additions & 0 deletions implement-and-rewrite-tests/implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,21 @@

export function getAngleType(angle) {
// TODO: Implement this function
if (angle === 90) {
return "Right angle";
} else if (angle > 0 && angle < 90) {
return "Acute angle";
} else if (angle > 90 && angle < 180) {
return "Obtuse angle";
} else if (angle === 180) {
return "Straight angle";
} else if (angle > 180 && angle < 360) {
return "Reflex angle";
} else if (angle === 0) {
return "Invalid angle";
} else if (angle === 360) {
return "Invalid angle";
} else (angle < 0 || angle > 360) {
return "Invalid angle";
}
}
8 changes: 8 additions & 0 deletions implement-and-rewrite-tests/implement/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@

export function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if (denominator === 0) {
return false;
} else if (numerator === 0) {
return false;
} else if (Math.abs(numerator) >= Math.abs(denominator)) {
return false;
}
return true;
}
22 changes: 22 additions & 0 deletions implement-and-rewrite-tests/implement/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,26 @@

export function getCardValue(card) {
// TODO: Implement this function
if (card.length >= 4) {
throw new Error(`Expected a number followed by a suit, but got "invalid"`);
} else if (card === "") {
throw new Error("Input needed");
}

let suit = card.slice(-1);
let cardNumber = card.slice(0, -1);
let value = Number(cardNumber);
if (!(suit === "♠" || suit === "♥" || suit === "♦" || suit === "♣")) {
throw new Error("Incorrect suit given");
} else if (cardNumber === "J" || cardNumber === "Q" || cardNumber === "K") {
return 10;
} else if (cardNumber === "A") {
return 11;
} else if (Number.isNaN(value)) {
throw new Error("Incorrect card number given");
} else if (value >= 2 && value <= 10) {
return value;
} else if (value < 2 || value > 10) {
throw new Error("Incorrect card number given");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,36 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
});

// Case 2: Right angle
test(`should return "Right angle" when (angle = 90)`, () => {
expect(getAngleType(90)).toEqual("Right angle");
});
// Case 3: Obtuse angles
// Case 4: Straight angle
test(`should return "Obtuse angle" when (90 < angle < 180)`, () => {
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(167)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
});
// Case 4: Straight angle
test(`should return "Straight angle" when (angle = 180)`, () => {
expect(getAngleType(180)).toEqual("Straight angle");
});
// Case 5: Reflex angles
test(`should return "Right angle" when (180 < angle < 360)`, () => {
expect(getAngleType(186)).toEqual("Reflex angle");
expect(getAngleType(270)).toEqual("Reflex angle");
expect(getAngleType(359)).toEqual("Reflex angle");
});
// Case 6: Invalid angles
test(`should return "Invalid angle" when (0 > angle > 360)`, () => {
expect(getAngleType(361)).toEqual("Invalid angle");
expect(getAngleType(396)).toEqual("Invalid angle");
expect(getAngleType(-57)).toEqual("Invalid angle");
});
Comment on lines +35 to +39

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be two boundary cases in this test suite. Can you think of them? Please add them. Thank you.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, I did not have Zero angle and Full angle. Was just looking at what was mentioned for the tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just they should be counted as invalid (per question's definition).

// Case 7: Zero angles
test(`should return "Invalid angle" when (angle = 0)`, () => {
expect(getAngleType(0)).toEqual("Invalid angle");
});
// Case 8: Full angles
test(`should return "Invalid angle" when (angle = 360)`, () => {
expect(getAngleType(360)).toEqual("Invalid angle");
});
Loading
Loading