@@ -21,12 +21,32 @@ test("should repeat the string count times", () => {
2121// When the repeatStr function is called with these inputs,
2222// Then it should return the original `str` without repetition.
2323
24+ test ( "Should return the original string with no repetitions" , ( ) => {
25+ const str = "hello" ;
26+ const count = 1 ;
27+ const repeatedStr = repeatedStr ( str , count ) ;
28+ expect ( repeatedStr ) . toEqual ( "hello" ) ;
29+ } ) ;
30+
2431// Case: Handle count of 0:
2532// Given a target string `str` and a `count` equal to 0,
2633// When the repeatStr function is called with these inputs,
2734// Then it should return an empty string.
35+ test ( "Should return an empty string" , ( ) => {
36+ const str = "hello" ;
37+ const count = 0 ;
38+ const repeatedStr = repeatedStr ( str , count ) ;
39+ expect ( repeatedStr ) . toEqual ( "" ) ;
40+ } ) ;
2841
2942// Case: Handle negative count:
3043// Given a target string `str` and a negative integer `count`,
3144// When the repeatStr function is called with these inputs,
3245// Then it should throw an error, as negative counts are not valid.
46+
47+ test ( "Should throw an error, as negative counts are not valid" , ( ) => {
48+ const str = "hello" ;
49+ const count = - 1 ;
50+ const repeatedStr = repeatedStr ( str , count ) ;
51+ expect ( repeatedStr ) . toThrow ( Error ) ;
52+ } ) ;
0 commit comments