Skip to content

Commit b5179b5

Browse files
committed
Merge changes
2 parents 938dbcf + 5dc9452 commit b5179b5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Sprint-3/2-practice-tdd/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Write the tests _before_ the code that will make them pass.
99
Recommended order:
1010

1111
1. `count.test.js`
12-
1. `repeat.test.js`
12+
1. `repeat-str.test.js`
1313
1. `get-ordinal-number.test.js`
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function repeat(str, count) {
1+
function repeatStr(str, count) {
22
if (count === 0) {
33
return "";
44
}
@@ -17,4 +17,4 @@ function repeat(str, count) {
1717
return repeatedStrCountTimes;
1818
}
1919

20-
module.exports = repeat;
20+
module.exports = repeatStr;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
// Implement a function repeat
2-
const repeat = require("./repeat");
1+
// Implement a function repeatStr
2+
const repeatStr = require("./repeat-str");
33
// Given a target string str and a positive integer count,
4-
// When the repeat function is called with these inputs,
4+
// When the repeatStr function is called with these inputs,
55
// Then it should:
66

77
// case: repeat String:
88
// Given a target string str and a positive integer count,
9-
// When the repeat function is called with these inputs,
9+
// When the repeatStr function is called with these inputs,
1010
// Then it should repeat the str count times and return a new string containing the repeated str values.
1111

1212
test("should repeat the string count times", () => {
1313
const str = "hello";
1414
const count = 3;
15-
const repeatedStr = repeat(str, count);
15+
const repeatedStr = repeatStr(str, count);
1616
expect(repeatedStr).toEqual("hellohellohello");
1717
});
1818

1919
// case: handle Count of 1:
2020
// Given a target string str and a count equal to 1,
21-
// When the repeat function is called with these inputs,
21+
// When the repeatStr function is called with these inputs,
2222
// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.
2323
test("should return the original string without repetition if count equal to 1", () => {
2424
const str = "Alone";
2525
const count = 1;
26-
const repeatedStr = repeat(str, count);
26+
const repeatedStr = repeatStr(str, count);
2727
expect(repeatedStr).toEqual("Alone");
2828
});
2929

3030
// case: Handle Count of 0:
3131
// Given a target string str and a count equal to 0,
32-
// When the repeat function is called with these inputs,
32+
// When the repeatStr function is called with these inputs,
3333
// Then it should return an empty string, ensuring that a count of 0 results in an empty output.
3434
test("should return an empty string if count equal to 0", () => {
3535
const str = "nonsense";
3636
const count = 0;
37-
const repeatedStr = repeat(str, count);
37+
const repeatedStr = repeatStr(str, count);
3838
expect(repeatedStr).toEqual("");
3939
});
4040

4141
// case: Negative Count:
4242
// Given a target string str and a negative integer count,
43-
// When the repeat function is called with these inputs,
43+
// When the repeatStr 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.
4545
test("should return an appropriate error message if count equal to a negative integer", () => {
4646
const str = "negative";
4747
const count = -5;
48-
const repeatedStr = repeat(str, count);
48+
const repeatedStr = repeatStr(str, count);
4949
expect(repeatedStr).toEqual("Error! Negative counts are not valid!");
5050
});

0 commit comments

Comments
 (0)