@@ -8,8 +8,7 @@ const repeatStr = require("./repeat-str");
88// Given a target string `str` and a positive integer `count` greater than 1,
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.
11-
12- test ( "should repeat the string count times" , ( ) => {
11+ test ( "should repeat the string 3 times" , ( ) => {
1312 const str = "hello" ;
1413 const count = 3 ;
1514 const repeatedStr = repeatStr ( str , count ) ;
@@ -20,13 +19,30 @@ test("should repeat the string count times", () => {
2019// Given a target string `str` and a `count` equal to 1,
2120// When the repeatStr function is called with these inputs,
2221// Then it should return the original `str` without repetition.
22+ test ( "should not repeat string with a count of 1" , ( ) => {
23+ const str = "hello" ;
24+ const count = 1 ;
25+ const repeatedStr = repeatStr ( str , count ) ;
26+ expect ( repeatedStr ) . toEqual ( "hello" ) ;
27+ } ) ;
2328
2429// Case: Handle count of 0:
2530// Given a target string `str` and a `count` equal to 0,
2631// When the repeatStr function is called with these inputs,
2732// Then it should return an empty string.
33+ test ( "should return empty string with a count of 0" , ( ) => {
34+ const str = "hello" ;
35+ const count = 0 ;
36+ const repeatedStr = repeatStr ( str , count ) ;
37+ expect ( repeatedStr ) . toEqual ( "" ) ;
38+ } ) ;
2839
2940// Case: Handle negative count:
3041// Given a target string `str` and a negative integer `count`,
3142// When the repeatStr function is called with these inputs,
3243// Then it should throw an error, as negative counts are not valid.
44+ test ( "should throw error when count < 0" , ( ) => {
45+ const str = "hello" ;
46+ const count = - 2 ;
47+ expect ( ( ) => repeatStr ( str , count ) ) . toThrow ( ) ;
48+ } ) ;
0 commit comments