Skip to content

Commit 88aeaaf

Browse files
committed
format document
1 parent 5114047 commit 88aeaaf

9 files changed

Lines changed: 4599 additions & 14 deletions

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {getAngleType} from '../implement/1-get-angle-type.js';
1+
import { getAngleType } from "../implement/1-get-angle-type.js";
22
import assert from "node:assert";
33
import test from "node:test";
44

@@ -29,4 +29,3 @@ test("Classifies boundary and invalid angles", () => {
2929
assert.equal(getAngleType(365), "Invalid angle");
3030
assert.equal(getAngleType(-10), "Invalid angle");
3131
});
32-

‎implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
22
import assert from "node:assert";
33
import test from "node:test";
44

5-
65
// TODO: Write tests to cover all cases.
76
// What combinations of numerators and denominators should you test?
87

‎implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {getCardValue} from "../implement/3-get-card-value.js";
1+
import { getCardValue } from "../implement/3-get-card-value.js";
22
import assert from "node:assert";
33
import test from "node:test";
44

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

87
test("Valid number card", () => {
@@ -18,7 +17,11 @@ test("Valid ace card", () => {
1817
});
1918

2019
test("Arbitrary non-card string", () => {
21-
assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error");
20+
assert.throws(
21+
() => getCardValue("invalid"),
22+
/Expected a number followed by a suit, but got "invalid"/,
23+
"Expected clear error"
24+
);
2225
});
2326

2427
// TODO: What other invalid card cases can you think of?

‎implement-and-rewrite-tests/implement/2-is-proper-fraction.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
// execute the code to ensure all tests pass.
1515

1616
export function isProperFraction(numerator, denominator) {
17-
if (numerator < denominator) {
18-
return "true";
19-
} return "false";
17+
if (numerator < denominator) {
18+
return "true";
19+
}
20+
return "false";
2021
}
21-
22-

‎implement-and-rewrite-tests/implement/3-get-card-value.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function getCardValue(card) {
5353
const validSuit = ["♠", "♥", "♦", "♣"].includes(suit);
5454

5555
if (!validRank || !validSuit || card.length > 3 || card.length < 2) {
56-
throw new Error (`Expected a number followed by a suit, but got "invalid"`);
56+
throw new Error(`Expected a number followed by a suit, but got "invalid"`);
5757
}
5858

5959
if (rank === "A") {

‎implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ test(`should return false when denominator is less than numerator`, () => {
1717

1818
test(`should true when denominator and numerator are negative`, () => {
1919
expect(isProperFraction(-5, -2)).toEqual("true");
20-
});
20+
});

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ test(`Expected a number followed by a suit, but got invalid`, () => {
2828
// To learn how to test whether a function throws an error as expected in Jest,
2929
// please refer to the Jest documentation:
3030
// https://jestjs.io/docs/expect#tothrowerror
31-

0 commit comments

Comments
 (0)