File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,35 @@ test("should return an empty string when count is 0", () => {
2929test ( "should throw an error when count is negative" , ( ) => {
3030 const str = "Hello World!" ;
3131 const count = - 1 ;
32+ expect ( ( ) => repeatStr ( str , count ) ) . toThrow ( ) ;
33+ } ) ;
34+ // Case: empty string with count of 3
35+ test ( "should return an empty string when string is empty and count is 3" , ( ) => {
36+ const str = "" ;
37+ const count = 3 ;
38+ const repeatedStr = repeatStr ( str , count ) ;
39+ expect ( repeatedStr ) . toEqual ( "" ) ;
40+ } ) ;
41+
42+ // Case: empty string with count of 1
43+ test ( "should return an empty string when string is empty and count is 1" , ( ) => {
44+ const str = "" ;
45+ const count = 1 ;
46+ const repeatedStr = repeatStr ( str , count ) ;
47+ expect ( repeatedStr ) . toEqual ( "" ) ;
48+ } ) ;
3249
50+ // Case: empty string with count of 0
51+ test ( "should return an empty string when string is empty and count is 0" , ( ) => {
52+ const str = "" ;
53+ const count = 0 ;
54+ const repeatedStr = repeatStr ( str , count ) ;
55+ expect ( repeatedStr ) . toEqual ( "" ) ;
56+ } ) ;
57+
58+ // Case: empty string with negative count
59+ test ( "should throw an error when string is empty and count is negative" , ( ) => {
60+ const str = "" ;
61+ const count = - 1 ;
3362 expect ( ( ) => repeatStr ( str , count ) ) . toThrow ( ) ;
34- } ) ;
63+ } ) ;
You can’t perform that action at this time.
0 commit comments