1- // Implement a function repeat
2- const repeat = require ( "./repeat" ) ;
31
2+ // Implement a function repeatStr
3+ const repeatStr = require ( "./repeat-str" ) ;
44// Given a target string str and a positive integer count,
5- // When the repeat function is called with these inputs,
5+ // When the repeatStr function is called with these inputs,
66// Then it should:
77
88// case: repeat String:
99// Given a target string str and a positive integer count,
10- // When the repeat function is called with these inputs,
10+ // When the repeatStr function is called with these inputs,
1111// Then it should repeat the str count times and return a new string containing the repeated str values.
1212
1313test ( "should repeat the string count times" , ( ) => {
1414 const str = "hello" ;
1515 const count = 3 ;
16- const repeatedStr = repeat ( str , count ) ;
16+ const repeatedStr = repeatStr ( str , count ) ;
1717 expect ( repeatedStr ) . toEqual ( "hellohellohello" ) ;
1818} ) ;
1919
2020// case: handle Count of 1:
2121// Given a target string str and a count equal to 1,
22- // When the repeat function is called with these inputs,
22+ // When the repeatStr function is called with these inputs,
2323// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.
2424test ( "should return the original string when count is 1" , ( ) => {
2525 const str = "hello" ;
@@ -30,7 +30,7 @@ test("should return the original string when count is 1", () => {
3030
3131// case: Handle Count of 0:
3232// Given a target string str and a count equal to 0,
33- // When the repeat function is called with these inputs,
33+ // When the repeatStr function is called with these inputs,
3434// Then it should return an empty string, ensuring that a count of 0 results in an empty output.
3535test ( "should return an empty string when count is 0" , ( ) => {
3636 const str = "hello" ;
@@ -41,7 +41,7 @@ test("should return an empty string when count is 0", () => {
4141
4242// case: Negative Count:
4343// Given a target string str and a negative integer count,
44- // When the repeat function is called with these inputs,
44+ // When the repeatStr function is called with these inputs,
4545// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
4646test ( "should throw an error for negative count" , ( ) => {
4747 const str = "hello" ;
0 commit comments