Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
301ea63
List edge cases for test.
Sep 28, 2026
2501561
Update list.
Sep 28, 2026
63e477b
Add an if condition to check midnight
Sep 28, 2026
a8e1b2d
Add another case to test midnight
Sep 28, 2026
9e2cef8
Add test case 00:01 to 12:01 am
Sep 28, 2026
2ba2e34
Add condition for checking midday 12 pm
Sep 28, 2026
06d5f91
Add test case for 01:00 to 01:00 am
Sep 28, 2026
3dc6da6
Add test case for 11:59 to 11:59 am
Sep 28, 2026
1e6cb55
Add test case for 12:01 to 12:01 pm
Sep 28, 2026
61b2ce7
Add test case for 13:00 to 1:00 pm
Sep 28, 2026
0407869
Add test case fo 23:59 to 11:59 pm
Sep 28, 2026
06d3f9a
Add padStart method to hours
Sep 28, 2026
598f744
Add more description.
Sep 28, 2026
e6fde3b
Add padStart method to convert 23:00 to 01:00pm
Sep 29, 2026
c2f743c
Edit comments
Sep 29, 2026
e7ff9c7
Inline code directly into return statement
Sep 30, 2026
751fb78
Change am and pm to lower case and update description.
Sep 30, 2026
4707f5a
Unreachable code.
Sep 30, 2026
f504687
Remove unreachable and redundant code.
Sep 30, 2026
d9197c4
Remove unused code
Sep 30, 2026
9494c3d
Update function to work for any input.
Sep 30, 2026
582699c
Format code with prettier.
Sep 30, 2026
b806b41
Stop tracking files
Oct 3, 2026
fcf27e7
Stop tracking files
Oct 3, 2026
04f544f
Restore files unrelated to this PR
Oct 3, 2026
4815e87
Add if condition for checking right angle.
Oct 3, 2026
9dc9e1f
Write test for Acute angle.
Oct 3, 2026
10b0d0f
Write test for Obtuse angle.
Oct 3, 2026
cccf002
Add if condition for checking Acute angle.
Oct 3, 2026
ed2729e
Add if condition for checking Obtuse angle.
Oct 3, 2026
4fa3e6c
Write test for invalid angles
Oct 3, 2026
ea5fa0f
Add final if condition for checking invalid angle
Oct 3, 2026
6102a89
Add boundary case test for acute angle.
Oct 4, 2026
717584d
Add if condition for checking invalid inputs.
Oct 4, 2026
fed8ddd
Add boundary test cases for multiple angles.
Oct 4, 2026
bb815ef
Add = operator for checking 360 degrees is included
Oct 4, 2026
c8fc9dd
Add boundary test cases.
Oct 5, 2026
3a565e9
Add angle type boundary tests
Oct 5, 2026
c80ed87
Add angle type boundary tests
Oct 5, 2026
38c28b3
Implement if condition to check propr function.
Oct 5, 2026
f12c635
Delete not needed test.
Oct 6, 2026
48b8dae
Write cases for testing proper and improper fractions.
Oct 6, 2026
d5091de
Update tests description.
Oct 6, 2026
fa07e40
Implement if condition to check card value
Oct 7, 2026
651191c
Check valid card ranks
russom-g Oct 12, 2026
53d733c
Add test cases for single-digit card
russom-g Oct 12, 2026
699f8c0
Add test cases for invalid card
russom-g Oct 12, 2026
63b1d20
Add test case for Obtuse angle
russom-g Oct 12, 2026
c0bc7b7
Add test cases for Straight, Reflex, and Invalid angles.
russom-g Oct 12, 2026
eb68334
Write multiple test cases for proper and improper fraction
russom-g Oct 12, 2026
3d93bc4
Add more test cases for Ace and face cards
russom-g Oct 13, 2026
b9732cb
Write test cases for cards number 2 -10
russom-g Oct 13, 2026
66f6482
Correct spelling error
russom-g Oct 13, 2026
7f0c6c8
Write test cases for invalid cards
russom-g Oct 13, 2026
0a2de27
Format code with prettier.
russom-g Oct 13, 2026
3e40397
Fix spelling error.
russom-g Oct 13, 2026
ad4fae0
Fix spelling error.
russom-g Oct 13, 2026
b8ba7fd
Format code with prettier.
russom-g Oct 13, 2026
0c75ac6
Restore dead-code files to match main
russom-g Oct 13, 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 @@ -6,7 +6,59 @@ import { getAngleType } from "../implement/1-get-angle-type.js";
// TODO: Write tests to cover all cases, including boundary and invalid cases.
// Example: Identify Right Angles

test("Classifies right angles", () => {
test("Classifies Acute angles", () => {
const Acute = getAngleType(1);
assert.equal(Acute, "Acute angle");

const Acute1 = getAngleType(45);
assert.equal(Acute1, "Acute angle");

const Acute2 = getAngleType(89);
assert.equal(Acute2, "Acute angle");
});

test("Classifies Right angles", () => {
const right = getAngleType(90);
assert.equal(right, "Right angle");
});

test("Classifies Obtuse angles", () => {
const Obtuse = getAngleType(91);
assert.equal(Obtuse, "Obtuse angle");

const Obtuse1 = getAngleType(120);
assert.equal(Obtuse1, "Obtuse angle");

const Obtuse2 = getAngleType(179);
assert.equal(Obtuse2, "Obtuse angle");
});

test("Classifies Straight angles", () => {
const Straight = getAngleType(180);
assert.equal(Straight, "Straight angle");
});

test("Classifies Reflex angles", () => {
const Reflex = getAngleType(181);
assert.equal(Reflex, "Reflex angle");

const Reflex1 = getAngleType(299);
assert.equal(Reflex1, "Reflex angle");

const Reflex2 = getAngleType(360);
assert.equal(Reflex2, "Reflex angle");
});

test("Classifies Invalid angles", () => {
const Invalid = getAngleType(0);
assert.equal(Invalid, "Invalid angle");

const Invalid1 = getAngleType(361);
assert.equal(Invalid1, "Invalid angle");

const Invalid2 = getAngleType(399);
assert.equal(Invalid2, "Invalid angle");

const Invalid3 = getAngleType(-7);
assert.equal(Invalid3, "Invalid angle");
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,58 @@ test("Basic proper fraction", () => {
// Example: 1/2 is a proper fraction
assert.equal(isProperFraction(1, 2), true);
});

// Proper fraction
test("Decimal proper fraction", () => {
assert.equal(isProperFraction(0.5, 1.5), true);
});

test("0 numerator proper fraction", () => {
assert.equal(isProperFraction(0, 5), true);
});

test("Negative numerator proper fraction", () => {
assert.equal(isProperFraction(-9, 1), true);
});

test("Both negative proper fraction", () => {
assert.equal(isProperFraction(-7, -3), true);
});

test("Large number proper fraction", () => {
assert.equal(isProperFraction(999, 1000), true);
});

test("Very small denominator proper fraction", () => {
assert.equal(isProperFraction(1, 1000000), true);
});

// Improper fractions

test("Decimal improper fraction", () => {
assert.equal(isProperFraction(1.2, 1.1), false);
});

test("Large numerator improper fraction", () => {
assert.equal(isProperFraction(5, 3), false);
});

test("Equal numbers improper fraction", () => {
assert.equal(isProperFraction(4, 4), false);
});

test("0 denominator improper fraction", () => {
assert.equal(isProperFraction(7, 0), false);
});

test("Both numbers 0 improper fraction", () => {
assert.equal(isProperFraction(0, 0), false);
});

test("Negative numbers improper fraction", () => {
assert.equal(isProperFraction(-4, -4), false);
});

test("Negative denominator improper fraction", () => {
assert.equal(isProperFraction(2, -9), false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,68 @@ import { getCardValue } from "../implement/3-get-card-value.js";

// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.

test("Valid Ace card", () => {
assert.equal(getCardValue("A♠"), 11);
});

test("Valid Jack card", () => {
assert.equal(getCardValue("J♥"), 10);
});

test("Valid Queen card", () => {
assert.equal(getCardValue("Q♣"), 10);
});

test("Valid King card", () => {
assert.equal(getCardValue("K♦"), 10);
});

test("Valid double-digit card", () => {
assert.equal(getCardValue("10♣"), 10);
});

test("Valid single-digit card", () => {
assert.equal(getCardValue("9♠"), 9);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("8♥"), 8);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("7♣"), 7);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("6♦"), 6);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("5♥"), 5);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("4♦"), 4);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("3♠"), 3);
});
test("Valid single-digit card", () => {
assert.equal(getCardValue("2♣"), 2);
});

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?

test("Invalid cards", () => {
assert.throws(() => getCardValue(""), "invalid");
assert.throws(() => getCardValue("♠"), "invalid");
assert.throws(() => getCardValue("A"), "invalid");
assert.throws(() => getCardValue("5"), "invalid");
assert.throws(() => getCardValue("1♠"), "invalid");
assert.throws(() => getCardValue("0♠"), "invalid");
assert.throws(() => getCardValue("11♠"), "invalid");
assert.throws(() => getCardValue("X♠"), "invalid");
assert.throws(() => getCardValue("5♠♥"), "invalid");
});
13 changes: 13 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,17 @@

export function getAngleType(angle) {
// TODO: Implement this function
if (angle > 0 && angle < 90) {
return "Acute angle";
} else if (angle === 90) {
return "Right 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 {
return "Invalid angle";
}
}
5 changes: 5 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,9 @@

export function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if (numerator < denominator) {
return true;
} else {
return false;
}
}
16 changes: 16 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,20 @@

export function getCardValue(card) {
// TODO: Implement this function
if (typeof card !== "string") {
throw new Error("Invalid");
}
const rank = card.slice(0, -1);

if (rank === "A") {
return 11;
}
if (rank === "J" || rank === "Q" || rank === "K") {
return 10;
}
const value = Number(rank);
if (Number.isInteger(value) && value >= 2 && value <= 10) {
return value;
}
throw new Error(`Expected a number followed by a suit, but got "${card}"`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,33 @@ 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
test(`should return "Obtuse angle" when (90 > angle < 180)`, () => {
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(120)).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 "Reflex angle" when (180 > angle <= 360)`, () => {
expect(getAngleType(181)).toEqual("Reflex angle");
expect(getAngleType(299)).toEqual("Reflex angle");
expect(getAngleType(360)).toEqual("Reflex angle");
});

// Case 6: Invalid angles
test(`should return "Invalid angle"`, () => {
expect(getAngleType(0)).toEqual("Invalid angle");
expect(getAngleType(361)).toEqual("Invalid angle");
expect(getAngleType(399)).toEqual("Invalid angle");
expect(getAngleType(-7)).toEqual("Invalid angle");
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,56 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
test(`should return false when denominator is zero`, () => {
expect(isProperFraction(1, 0)).toEqual(false);
});

test(`should return true for basic proper fraction`, () => {
expect(isProperFraction(1, 2)).toEqual(true);
});

test(`should return true for decimal proper fraction`, () => {
expect(isProperFraction(0.5, 1.5)).toEqual(true);
});

test(`should return true for 0 numerator proper fraction`, () => {
expect(isProperFraction(0, 5)).toEqual(true);
});

test(`should return true for negative numerator proper fraction`, () => {
expect(isProperFraction(-9, 1)).toEqual(true);
});

test(`should return true for negative proper fraction`, () => {
expect(isProperFraction(-7, -3)).toEqual(true);
});

test(`should return true for very small denominator proper fraction`, () => {
expect(isProperFraction(1, 1000000)).toEqual(true);
});

// Improper fractions
test(`should return false for very small denominator proper fraction`, () => {
expect(isProperFraction(1.2, 1.1)).toEqual(false);
});

test(`should return false for large numerator improper fraction`, () => {
expect(isProperFraction(5, 3)).toEqual(false);
});

test(`should return false for both equal numbers improper fraction`, () => {
expect(isProperFraction(4, 4)).toEqual(false);
});

test(`should return false for 0 denominator improper fraction`, () => {
expect(isProperFraction(7, 0)).toEqual(false);
});

test(`should return false for both 0 improper fraction`, () => {
expect(isProperFraction(0, 0)).toEqual(false);
});

test(`should return false for both negative improper fraction`, () => {
expect(isProperFraction(-4, -4)).toEqual(false);
});

test(`should return false for negative denominator improper fraction`, () => {
expect(isProperFraction(2, -9)).toEqual(false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@ test(`Should return 11 when given an ace card`, () => {
expect(getCardValue("A♠")).toEqual(11);
});

// Case 2: Number Cards (2-10)
test(`Should return its numeric value when given a number card`, () => {
expect(getCardValue("2♥")).toEqual(2);
expect(getCardValue("3♣")).toEqual(3);
expect(getCardValue("4♠")).toEqual(4);
expect(getCardValue("5♦")).toEqual(5);
expect(getCardValue("6♣")).toEqual(6);
expect(getCardValue("7♠")).toEqual(7);
expect(getCardValue("8♥")).toEqual(8);
expect(getCardValue("9♣")).toEqual(9);
expect(getCardValue("10♦")).toEqual(10);
});

// Case 3: Face Cards (J, Q, K)
test(`Should return 10 when given a face card`, () => {
expect(getCardValue("K♠")).toEqual(10);
expect(getCardValue("Q♠")).toEqual(10);
expect(getCardValue("K♦")).toEqual(10);
});

// Case 4: Invalid Cards

test(`Should return "Invalid" when given an invalid card`, () => {
expect(() => getCardValue("")).toThrow();
expect(() => getCardValue("♠")).toThrow();
expect(() => getCardValue("A")).toThrow();
expect(() => getCardValue("5")).toThrow();
expect(() => getCardValue("1♠")).toThrow();
expect(() => getCardValue("0♠")).toThrow();
expect(() => getCardValue("11♠")).toThrow();
expect(() => getCardValue("X♠")).toThrow();
expect(() => getCardValue("5♠♥")).toThrow();
});

// Suggestion: Group the remaining test data into these categories:
// Number Cards (2-10)
// Face Cards (J, Q, K)
Expand All @@ -15,4 +49,3 @@ test(`Should return 11 when given an ace card`, () => {
// To learn how to test whether a function throws an error as expected in Jest,
// please refer to the Jest documentation:
// https://jestjs.io/docs/expect#tothrowerror

Loading