Skip to content

Commit 3fd455a

Browse files
committed
fixing test descriptions (adding brief description should and when ) based on mentor feedback
1 parent c382bec commit 3fd455a

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

Sprint-3/2-practice-tdd/count.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test("should count multiple occurrences of a character", () => {
2222
// And a character `char` that does not exist within `str`.
2323
// When the function is called with these inputs,
2424
// Then it should return 0, indicating that no occurrences of `char` were found.
25-
test("it should return 0 because the character doesn't occurrences", () => {
25+
test("returns 0 when the character does not exist in the string", () => {
2626
const str = "The character have no match";
2727
const char = "z";
2828
const count = countChar(str, char);
@@ -33,7 +33,7 @@ test("it should return 0 because the character doesn't occurrences", () => {
3333
// And a character `char` that have 1 character exist in `str`.
3434
// When the function is called with these inputs,
3535
// Then it should return 1, indicating that 1 occurrences of `char` were found.
36-
test("it should return 1 because the character occurrences 1 time", () => {
36+
test("returns 1 when the character appears once in the string", () => {
3737
const str = "code your future";
3838
const char = "f";
3939
const count = countChar(str, char);

Sprint-3/2-practice-tdd/get-ordinal-number.test.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,38 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
1818
expect(getOrdinalNumber(21)).toEqual("21st");
1919
expect(getOrdinalNumber(131)).toEqual("131st");
2020
});
21-
// Case 1: Numbers ending with 1 (but not 11)
22-
// When the number ends with 1, except those ending with 11,
21+
// Case 2: Numbers ending with 2 (but not 12)
22+
// When the number ends with 1, except those ending with 12,
2323
// Then the function should return a string by appending "st" to the number.
2424
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
2525
expect(getOrdinalNumber(2)).toEqual("2nd");
2626
expect(getOrdinalNumber(42)).toEqual("42nd");
2727
expect(getOrdinalNumber(1752)).toEqual("1752nd");
2828
});
29-
// Case 1: Numbers ending with 1 (but not 11)
30-
// When the number ends with 1, except those ending with 11,
29+
// Case 3: Numbers ending with 3 (but not 13)
30+
// When the number ends with 3, except those ending with 13,
3131
// Then the function should return a string by appending "st" to the number.
3232
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
3333
expect(getOrdinalNumber(3)).toEqual("3rd");
3434
expect(getOrdinalNumber(83)).toEqual("83rd");
3535
expect(getOrdinalNumber(653)).toEqual("653rd");
3636
});
37-
// Case 1: Numbers ending with 1 (but not 11)
38-
// When the number ends with 1, except those ending with 11,
39-
// Then the function should return a string by appending "st" to the number.
40-
test("should append 'th' for numbers not ending with 1, 2 and 3 ", () => {
37+
// Case 4: Numbers ending with 4 through 9
38+
// When the number does not end with 1, 2 or 3,
39+
// Then the function should return a string by appending "th" to the number.
40+
test("should append 'th' for all other numbers that do not end with 1, 2 or 3", () => {
4141
expect(getOrdinalNumber(5)).toEqual("5th");
4242
expect(getOrdinalNumber(38)).toEqual("38th");
4343
expect(getOrdinalNumber(15678)).toEqual("15678th");
4444
});
45+
//Case 5: Numbers ending with 11, 12 and 13 (special exceptions)
46+
// When the number ends with 11, 12 or 13,
47+
// Then the function should return a string by appending "th" to the number.
48+
test("should append 'th' for numbers ending with 11, 12 and 13", () => {
49+
expect(getOrdinalNumber(11)).toEqual("11th");
50+
expect(getOrdinalNumber(12)).toEqual("12th");
51+
expect(getOrdinalNumber(13)).toEqual("13th");
52+
expect(getOrdinalNumber(111)).toEqual("111th");
53+
expect(getOrdinalNumber(112)).toEqual("112th");
54+
expect(getOrdinalNumber(113)).toEqual("113th");
55+
});

Sprint-3/2-practice-tdd/repeat-str.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const repeatStr = require("./repeat-str");
99
// When the repeatStr function is called with these inputs,
1010
// Then it should return a string that contains the original `str` repeated `count` times.
1111

12-
test("should repeat the string count times", () => {
12+
test("should return the string the given number of count when count is a positive number", () => {
1313
let word = "hello";
1414
let times = 3;
1515
const repeatedStr = repeatStr(word, times);
@@ -20,7 +20,7 @@ test("should repeat the string count times", () => {
2020
// Given a target string `str` and a `count` equal to 1,
2121
// When the repeatStr function is called with these inputs,
2222
// Then it should return the original `str` without repetition.
23-
test("should repeat the string count times", () => {
23+
test("should return the original string without repetition when count is 1", () => {
2424
let word = "code your future";
2525
let times = 1;
2626
const repeatedStr = repeatStr(word, times);
@@ -30,7 +30,7 @@ test("should repeat the string count times", () => {
3030
// Given a target string `str` and a `count` equal to 0,
3131
// When the repeatStr function is called with these inputs,
3232
// Then it should return an empty string.
33-
test("should repeat the string is empty ", () => {
33+
test("should return an empty string when the number of times is 0", () => {
3434
let word = "hello";
3535
let times = 0;
3636
const repeatedStr = repeatStr(word, times);
@@ -40,7 +40,7 @@ test("should repeat the string is empty ", () => {
4040
// Given a target string `str` and a negative integer `count`,
4141
// When the repeatStr function is called with these inputs,
4242
// Then it should throw an error, as negative counts are not valid.
43-
test("should repeat the string return negative number not allowed ", () => {
43+
test("should return a string 'negative number not allowed' when negative number passed", () => {
4444
let word = "hello";
4545
let times = -3;
4646
const repeatedStr = repeatStr(word, times);

0 commit comments

Comments
 (0)