Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ce76c0b
add empty lines for better readability in angle type tests
MattCarolus10 Oct 8, 2026
eb2d17d
implement getAngleType function to return "Right angle" for 90°
MattCarolus10 Oct 8, 2026
56c856c
add test case for classifying acute angles in getAngleType function
MattCarolus10 Oct 8, 2026
2e4e5e1
implement getAngleType function to return "Acute angle" for angles be…
MattCarolus10 Oct 8, 2026
fd1f878
add test case for classifying obtuse angles in getAngleType function
MattCarolus10 Oct 8, 2026
67bf79b
implement getAngleType function to return "Obtuse angle" for angles b…
MattCarolus10 Oct 8, 2026
b1a6630
add test case for classifying straight angles in getAngleType function
MattCarolus10 Oct 8, 2026
db4a27e
fix: correct expected output for straight angle classification test
MattCarolus10 Oct 8, 2026
7e8ad2f
fix: return "Straight angle" for angle equal to 180°
MattCarolus10 Oct 8, 2026
eeb2846
add test case for classifying reflex angles in getAngleType function
MattCarolus10 Oct 8, 2026
1807a2d
fix: add missing semicolons in getAngleType function
MattCarolus10 Oct 8, 2026
ad85b14
fix: add missing semicolons and correct test syntax in angle classifi…
MattCarolus10 Oct 8, 2026
325a7ee
fix: add missing semicolons and format test cases in angle classifica…
MattCarolus10 Oct 8, 2026
2d57566
fix: update invalid angle classification in getAngleType function
MattCarolus10 Oct 8, 2026
69af44c
fix: update invalid angle test case in getAngleType function
MattCarolus10 Oct 8, 2026
3eb0813
feat: implement isProperFraction function to evaluate proper fractions
MattCarolus10 Oct 8, 2026
41d025e
fix: correct isProperFraction logic to return boolean values
MattCarolus10 Oct 8, 2026
115eb01
fix: correct assertion in isProperFraction test to match expected boo…
MattCarolus10 Oct 8, 2026
e029b5a
fix: correct return value in isProperFraction function to return bool…
MattCarolus10 Oct 8, 2026
55d9b0f
fix: return boolean true in isProperFraction function instead of string
MattCarolus10 Oct 8, 2026
09732da
fix: update isProperFraction logic to correctly evaluate proper fract…
MattCarolus10 Oct 8, 2026
268b7e4
test: add assertion for improper fraction case in isProperFraction test
MattCarolus10 Oct 8, 2026
f02a167
test: add additional test cases for isProperFraction function
MattCarolus10 Oct 8, 2026
f423445
test: add assertion for negative numerator case in isProperFraction test
MattCarolus10 Oct 8, 2026
3f5bc58
test: add assertion for negative denominator case in isProperFraction…
MattCarolus10 Oct 8, 2026
388bb92
fix: refine isProperFraction logic to handle negative numerator and d…
MattCarolus10 Oct 8, 2026
addec7e
refactor: remove unnecessary blank line in isProperFraction test
MattCarolus10 Oct 8, 2026
7b32fd3
refactor: improve formatting and consistency in isProperFraction func…
MattCarolus10 Oct 8, 2026
3007cee
refactor: remove unnecessary comments from isProperFraction implement…
MattCarolus10 Oct 8, 2026
7335f61
refactor: remove TODO comments from isProperFraction test file
MattCarolus10 Oct 8, 2026
fd4c2d8
refactor: comment out unused test cases and implement basic getCardVa…
MattCarolus10 Oct 9, 2026
3ff46c7
refactor: uncomment valid single-digit card test in getCardValue test…
MattCarolus10 Oct 9, 2026
9f20280
refactor: fix getCardValue function to return numeric value for numbe…
MattCarolus10 Oct 9, 2026
92c9dd3
refactor: add test for face cards to return correct value
MattCarolus10 Oct 9, 2026
08a8dac
refactor: fix face card test cases to use correct syntax for getCardV…
MattCarolus10 Oct 9, 2026
5422d78
refactor: fix formatting and structure in getCardValue function for c…
MattCarolus10 Oct 9, 2026
ab0f20e
refactor: uncomment test for arbitrary non-card string and enhance er…
MattCarolus10 Oct 9, 2026
0ac8992
refactor: add newline at the end of 3-get-card-value.js for consistency
MattCarolus10 Oct 9, 2026
9546060
refactor: clean up comments and improve formatting in getCardValue fu…
MattCarolus10 Oct 9, 2026
310b716
refactor: remove TODO comments and improve formatting in test cases f…
MattCarolus10 Oct 9, 2026
cd6cf1e
refactor: add additional test cases for card value validation and err…
MattCarolus10 Oct 9, 2026
c08bc7b
refactor: add test case for handling extra characters in card input
MattCarolus10 Oct 9, 2026
23f8f8d
refactor: improve formatting in missing or broken suit test cases
MattCarolus10 Oct 9, 2026
732e5ac
refactor: ensure rank is consistently uppercased in getCardValue func…
MattCarolus10 Oct 9, 2026
3b3d156
refactor: fix syntax in test case for handling extra characters in ca…
MattCarolus10 Oct 9, 2026
cdb038b
refactor: fix syntax error in test case for handling extra characters…
MattCarolus10 Oct 9, 2026
5d45a20
refactor: fix syntax error in test case for adding junk characters to…
MattCarolus10 Oct 9, 2026
362a572
refactor: add test case for right angle in getAngleType function
MattCarolus10 Oct 9, 2026
34bd7f8
refactor: add test case for obtuse angles in getAngleType function
MattCarolus10 Oct 9, 2026
068bdef
refactor: add test case for straight angle in getAngleType function
MattCarolus10 Oct 9, 2026
2c43396
refactor: add tests for reflex and invalid angles in getAngleType fun…
MattCarolus10 Oct 9, 2026
d478206
refactor: add additional test cases for invalid angles in getAngleTyp…
MattCarolus10 Oct 9, 2026
94d3efb
refactor: remove unnecessary whitespace in getAngleType test file
MattCarolus10 Oct 9, 2026
a9c25bf
refactor: remove commented-out cases in getAngleType test file
MattCarolus10 Oct 9, 2026
0297184
refactor: clean up whitespace and comments in getAngleType test file
MattCarolus10 Oct 9, 2026
a4aed0f
test: add test case for negative denominator in isProperFraction func…
MattCarolus10 Oct 9, 2026
9249f9a
test: add test case for valid denominator in isProperFraction function
MattCarolus10 Oct 9, 2026
c96b8e8
test: add test case for zero numerator in isProperFraction function
MattCarolus10 Oct 9, 2026
71fad68
test: add test case for equality of numerator and denominator in isPr…
MattCarolus10 Oct 9, 2026
bc356fb
test: clarify test description for proper fraction denominator compar…
MattCarolus10 Oct 9, 2026
02239f4
fix: ensure proper fraction logic handles equality of numerator and d…
MattCarolus10 Oct 9, 2026
32e11b4
test: add test case for face cards "J", "Q", and "K" in getCardValue …
MattCarolus10 Oct 9, 2026
84c10da
test: add additional test case for Number cards in getCardValue function
MattCarolus10 Oct 9, 2026
b78ad1b
fix: correct syntax by closing the Number card test case
MattCarolus10 Oct 9, 2026
91c33aa
test: add additional test case for invalid cards in getCardValue func…
MattCarolus10 Oct 9, 2026
2f56990
fix: remove redundant invalid card tests in getCardValue function
MattCarolus10 Oct 9, 2026
845c0d9
test: add test case to verify countChar returns 0 for non-existent ch…
MattCarolus10 Oct 9, 2026
10fd986
fix: implement countChar function to accurately count occurrences of …
MattCarolus10 Oct 9, 2026
9693c4b
test: add test cases for numbers ending with 2 in getOrdinalNumber fu…
MattCarolus10 Oct 9, 2026
3ad4ad1
test: add test cases for numbers ending with 3 in getOrdinalNumber fu…
MattCarolus10 Oct 9, 2026
ba47123
test: fix formatting in getOrdinalNumber test cases and add missing t…
MattCarolus10 Oct 9, 2026
fa8c3b8
fix: update getOrdinalNumber function to correctly calculate ordinal …
MattCarolus10 Oct 9, 2026
c01df9b
fix: correct logic in getOrdinalNumber function to handle ordinal suf…
MattCarolus10 Oct 9, 2026
b4e1243
fix: correct variable name in getOrdinalNumber function to ensure pro…
MattCarolus10 Oct 9, 2026
f84d7a0
fix: remove unnecessary console.log and ensure proper formatting in g…
MattCarolus10 Oct 9, 2026
2d138e0
fix: correct return value for ordinal suffix of 1 in getOrdinalNumber…
MattCarolus10 Oct 9, 2026
9dff0ae
fix: update return values in getOrdinalNumber function to use dynamic…
MattCarolus10 Oct 9, 2026
183aacc
test: add test case for repeating the string one time in repeatStr fu…
MattCarolus10 Oct 9, 2026
42606b6
test: add test case for returning an empty string when count is 0 in …
MattCarolus10 Oct 9, 2026
09bf246
test: add case to handle negative integer input in repeatStr function
MattCarolus10 Oct 9, 2026
2b76b09
fix: implement repeatStr function with error handling for negative co…
MattCarolus10 Oct 9, 2026
32c195a
fix: implement repeatStr function to return repeated string based on …
MattCarolus10 Oct 9, 2026
171b264
refactor: remove redundant comments from repeatStr test cases
MattCarolus10 Oct 9, 2026
a4b8f77
refactor: remove redundant comments from getOrdinalNumber test file
MattCarolus10 Oct 9, 2026
b7bd710
refactor: remove redundant comments from countChar test file
MattCarolus10 Oct 9, 2026
5de7ae0
refactor: remove TODO comments and suggestions from getCardValue test…
MattCarolus10 Oct 9, 2026
a2cb8ad
refactor: remove TODO comment and clean up test formatting in isPrope…
MattCarolus10 Oct 9, 2026
f97fa01
refactor: remove TODO comments and clean up test cases in getAngleTyp…
MattCarolus10 Oct 9, 2026
208e10a
refactor: remove TODO comments from getAngleType test file
MattCarolus10 Oct 9, 2026
a13105a
refactor: remove unnecessary comments from getAngleType function
MattCarolus10 Oct 9, 2026
d8e8974
refactor: add test case for password containing at least one uppercas…
MattCarolus10 Oct 10, 2026
8b50775
refactor: add test case for password containing at least one lowercas…
MattCarolus10 Oct 10, 2026
34edfce
refactor: add test case for password containing at least one number
MattCarolus10 Oct 10, 2026
a0fc1e8
refactor: add test case for password containing at least one special …
MattCarolus10 Oct 10, 2026
4b5f2f7
refactor: clean up test case formatting for password validation
MattCarolus10 Oct 10, 2026
88908c7
refactor: add test case to ensure password is not a previous password
MattCarolus10 Oct 10, 2026
36105df
refactor: update isValidPassword function to accept an additional par…
MattCarolus10 Oct 10, 2026
5337940
refactor: fix isValidPassword function to correctly check for previou…
MattCarolus10 Oct 10, 2026
8849988
refactor: fix parameter name in isValidPassword function for clarity
MattCarolus10 Oct 10, 2026
570fb97
refactor: fix condition in isValidPassword function to check against …
MattCarolus10 Oct 10, 2026
3cabf33
refactor: improve readability by adjusting whitespace in isValidPassw…
MattCarolus10 Oct 10, 2026
7fec32a
refactor: fix formatting issues in isValidPassword function for consi…
MattCarolus10 Oct 10, 2026
ebe8b44
restore sprint-3-stretch-exercises from main
MattCarolus10 Oct 10, 2026
1e85935
restore implement-and-rewrite-tests from main
MattCarolus10 Oct 10, 2026
242e70d
restore 1-get-angle-type.test.js from upstream/main
MattCarolus10 Oct 10, 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
9 changes: 8 additions & 1 deletion practice-tdd/count.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export function countChar(stringOfCharacters, findCharacter) {
return 5
let count = 0;
for (const char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}

return count;
}
21 changes: 6 additions & 15 deletions practice-tdd/count.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
// implement a function countChar that counts the number of times a character occurs in a string
import { countChar } from "./count.js";
// Given a string `str` and a single character `char` to search for,
// When the countChar function is called with these inputs,
// Then it should:

// Scenario: Multiple Occurrences
// Given the input string `str`,
// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
// When the function is called with these inputs,
// Then it should correctly count occurrences of `char`.

test("should count multiple occurrences of a character", () => {
const str = "aaaaa";
Expand All @@ -17,8 +7,9 @@ test("should count multiple occurrences of a character", () => {
expect(count).toEqual(5);
});

// Scenario: No Occurrences
// Given the input string `str`,
// And a character `char` that does not exist within `str`.
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.
test("Should return 0 when value does not exist in str", () => {
const str = "zzzzz";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(0);
});
18 changes: 17 additions & 1 deletion practice-tdd/get-ordinal-number.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
export function getOrdinalNumber(num) {
return "1st";
const lastDigit = num % 10;
const lastTwoDigits = num % 100;

if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {
return `${num}th`;
}
if (lastDigit === 1) {
return `${num}st`;
}
if (lastDigit === 2) {
return `${num}nd`;
}
if (lastDigit === 3) {
return `${num}rd`;
}
return `${num}th`;
}
console.log(getOrdinalNumber(21))
34 changes: 21 additions & 13 deletions practice-tdd/get-ordinal-number.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { getOrdinalNumber } from "./get-ordinal-number.js";
// In this week's prep, we started implementing getOrdinalNumber.

// Continue testing and implementing getOrdinalNumber for additional cases.
// Write your tests using Jest — remember to run your tests often for continual feedback.

// To ensure thorough testing, we need broad scenarios that cover all possible cases.
// Listing individual values, however, can quickly lead to an unmanageable number of test cases.
// Instead of writing tests for individual numbers, consider grouping all possible input values
// into meaningful categories. Then, select representative samples from each category to test.
// This approach improves coverage and makes our tests easier to maintain.

// Case 1: Numbers ending with 1 (but not 11)
// When the number ends with 1, except those ending with 11,
// Then the function should return a string by appending "st" to the number.
test("should append 'st' for numbers ending with 1, except those ending with 11", () => {
expect(getOrdinalNumber(1)).toEqual("1st");
expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(131)).toEqual("131st");
});

test("Should append 'nd' for numbers ending with 2, except those ending with 12", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
expect(getOrdinalNumber(22)).toEqual("22nd");
expect(getOrdinalNumber(122)).toEqual("122nd");
})

test("Should append 'rd' for numbers ending with 3, except those ending with 13", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(33)).toEqual("33rd");
expect(getOrdinalNumber(133)).toEqual("133rd");
})

test("Should append 'th' for all numbers including 11, 12, 13, except those ending in 1, 2, 3", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
expect(getOrdinalNumber(10)).toEqual("10th");
expect(getOrdinalNumber(111)).toEqual("111th");
})
14 changes: 10 additions & 4 deletions practice-tdd/repeat-str.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export function repeatStr() {
// Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).
// The goal is to re-implement that function, not to use it.
return "hellohellohello";
export function repeatStr(str, count) {

if (count < 0) {
throw new Error ("Negative counts are not allowed");
};
let result = "";
for (let i = 0; i < count; i++) {
result += str;
}
return result;;
}
38 changes: 17 additions & 21 deletions practice-tdd/repeat-str.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
// Implement a function repeatStr
import { repeatStr } from "./repeat-str.js";
// Given a target string `str` and a positive integer `count`,
// When the repeatStr function is called with these inputs,
// Then it should:

// Case: handle multiple repetitions:
// Given a target string `str` and a positive integer `count` greater than 1,
// When the repeatStr function is called with these inputs,
// Then it should return a string that contains the original `str` repeated `count` times.

test("should repeat the string count times", () => {
const str = "hello";
Expand All @@ -16,17 +7,22 @@ test("should repeat the string count times", () => {
expect(repeatedStr).toEqual("hellohellohello");
});

// Case: handle count of 1:
// Given a target string `str` and a `count` equal to 1,
// When the repeatStr function is called with these inputs,
// Then it should return the original `str` without repetition.
test("should repeat the string one time", () => {
const str = "hello";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hello");
});

// Case: Handle count of 0:
// Given a target string `str` and a `count` equal to 0,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string.
test("should return an empty string", () => {
const str = "hello";
const count = 0;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("");
});

// Case: Handle negative count:
// Given a target string `str` and a negative integer `count`,
// When the repeatStr function is called with these inputs,
// Then it should throw an error, as negative counts are not valid.
test("should return invalid when a negative integer is passed", () => {
const str = "hello";
const count = -2;
expect(() => repeatStr(str, count)).toThrow();
});
Loading