@@ -15,18 +15,56 @@ test("should repeat the string count times", () => {
1515 const repeatedStr = repeatStr ( str , count ) ;
1616 expect ( repeatedStr ) . toEqual ( "hellohellohello" ) ;
1717} ) ;
18+ test ( "should repeat the string count times" , ( ) => {
19+ const str = "codeyourfuture" ;
20+ const count = 2 ;
21+ const repeatedStr = repeatStr ( str , count ) ;
22+ expect ( repeatedStr ) . toEqual ( "codeyourfuturecodeyourfuture" ) ;
23+ } ) ;
1824
1925// Case: handle count of 1:
2026// Given a target string `str` and a `count` equal to 1,
2127// When the repeatStr function is called with these inputs,
2228// Then it should return the original `str` without repetition.
23-
29+ test ( "should repeat the string count times" , ( ) => {
30+ const str = "hello" ;
31+ const count = 1 ;
32+ const repeatedStr = repeatStr ( str , count ) ;
33+ expect ( repeatedStr ) . toEqual ( "hello" ) ;
34+ } ) ;
35+ test ( "should repeat the string count times" , ( ) => {
36+ const str = "codeyourfuture" ;
37+ const count = 1 ;
38+ const repeatedStr = repeatStr ( str , count ) ;
39+ expect ( repeatedStr ) . toEqual ( "codeyourfuture" ) ;
40+ } ) ;
2441// Case: Handle count of 0:
2542// Given a target string `str` and a `count` equal to 0,
2643// When the repeatStr function is called with these inputs,
2744// Then it should return an empty string.
28-
45+ test ( "should repeat the string count times" , ( ) => {
46+ const str = "hello" ;
47+ const count = 0 ;
48+ const repeatedStr = repeatStr ( str , count ) ;
49+ expect ( repeatedStr ) . toEqual ( "" ) ;
50+ } ) ;
51+ test ( "should repeat the string count times" , ( ) => {
52+ const str = "codeyourfuture" ;
53+ const count = 0 ;
54+ const repeatedStr = repeatStr ( str , count ) ;
55+ expect ( repeatedStr ) . toEqual ( "" ) ;
56+ } ) ;
2957// Case: Handle negative count:
3058// Given a target string `str` and a negative integer `count`,
3159// When the repeatStr function is called with these inputs,
3260// Then it should throw an error, as negative counts are not valid.
61+ test ( "should repeat the string count times" , ( ) => {
62+ const str = "hello" ;
63+ const count = - 4 ;
64+ expect ( ( ) => repeatStr ( str , count ) ) . toThrow ( "Invalid count" ) ;
65+ } ) ;
66+ test ( "should repeat the string count times" , ( ) => {
67+ const str = "codeyourfuture" ;
68+ const count = - 1 ;
69+ expect ( ( ) => repeatStr ( str , count ) ) . toThrow ( "Invalid count" ) ;
70+ } ) ;
0 commit comments