Skip to content

Commit ed2e57d

Browse files
authored
communicating with the comment to resolve the issue
1 parent 0c6b25c commit ed2e57d

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test("should count multiple occurrences of a character", () => {
3636
// And a character char that does not exist within the case-sensitive str,
3737
// When the function is called with these inputs,
3838
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.
39-
test("should count multiple occurrences of a character", () => {
39+
test("should count no occurrence of a character", () => {
4040
const str = "hello";
4141
const char = "a";
4242
const count = countChar(str, char);

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,9 @@ const getOrdinalNumber = require("./get-ordinal-number");
77
// Case 1: Identify the ordinal number for 1
88
// When the number is 1,
99
// Then the function should return "1st"
10-
test("append 'st' to numbers ending in 1, except those ending in 11 which is 11th", () => {
10+
test("append 'st' to numbers ending in 1, except those ending in 11", () => {
1111
expect( getOrdinalNumber(1) ).toEqual("1st");
12-
expect( getOrdinalNumber(11) ).toEqual("11th");
1312
expect( getOrdinalNumber(21) ).toEqual("21st");
1413
expect( getOrdinalNumber(221) ).toEqual("221st");
1514
});
1615

17-
test("append 'nd' to numbers ending in 2, except those ending in 12 which is 12th", () => {
18-
expect( getOrdinalNumber(2) ).toEqual("2nd");
19-
expect( getOrdinalNumber(12) ).toEqual("12th");
20-
expect( getOrdinalNumber(22) ).toEqual("22nd");
21-
expect( getOrdinalNumber(132) ).toEqual("132nd");
22-
});
23-
24-
test("append 'rd' to numbers ending in 3, except those ending in 13 which is 13th", () => {
25-
expect( getOrdinalNumber(3) ).toEqual("3rd");
26-
expect( getOrdinalNumber(13) ).toEqual("13th");
27-
expect( getOrdinalNumber(33) ).toEqual("33rd");
28-
expect( getOrdinalNumber(133) ).toEqual("133rd");
29-
});
30-

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
function repeat(word, n) {
22
if (typeof n !== 'number' || n < 0) {
3-
return "Count must be a non-negative integer";
4-
}
3+
throw new Error("Count must be a non-negative integer");
4+
}
55
if (n === 0) {
6-
return " ";
6+
return "";
77
}
88
return word.repeat(n);
99
}
1010

1111
module.exports = repeat;
12+
13+

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ test("should repeat the string count times", () => {
3535
const str = "hello";
3636
const count = 0;
3737
const repeatedStr = repeat(str, count);
38-
expect(repeatedStr).toEqual(" ");
38+
expect(repeatedStr).toEqual("");
3939
});
4040

4141
// case: Negative Count:
4242
// Given a target string str and a negative integer count,
4343
// When the repeat function is called with these inputs,
4444
// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
45+
4546
test("should repeat the string count times", () => {
4647
const str = "hello";
4748
const count = -1;
48-
const repeatedStr = repeat(str, count);
49-
expect(repeatedStr).toEqual("Count must be a non-negative integer");
50-
});
49+
expect(() => repeat(str, count)).toThrow("Count must be a non-negative integer");
50+
});

0 commit comments

Comments
 (0)