@@ -10,23 +10,27 @@ const repeatStr = require("./repeat-str");
1010// Then it should return a string that contains the original `str` repeated `count` times.
1111
1212test ( "should repeat the string count times" , ( ) => {
13- const str = "hello" ;
14- const count = 3 ;
15- const repeatedStr = repeatStr ( str , count ) ;
16- expect ( repeatedStr ) . toEqual ( "hellohellohello" ) ;
13+ expect ( repeatStr ( "Love" , 3 ) ) . toEqual ( "LoveLoveLove" ) ;
1714} ) ;
1815
1916// Case: handle count of 1:
2017// Given a target string `str` and a `count` equal to 1,
2118// When the repeatStr function is called with these inputs,
2219// Then it should return the original `str` without repetition.
23-
20+ test ( "should print the original string" , ( ) => {
21+ expect ( repeatStr ( "Love" , 1 ) ) . toEqual ( "Love" ) ;
22+ } ) ;
2423// Case: Handle count of 0:
2524// Given a target string `str` and a `count` equal to 0,
2625// When the repeatStr function is called with these inputs,
2726// Then it should return an empty string.
28-
27+ test ( "should return an empty string" , ( ) => {
28+ expect ( repeatStr ( "Love" , 0 ) ) . toEqual ( "" ) ;
29+ } ) ;
2930// Case: Handle negative count:
3031// Given a target string `str` and a negative integer `count`,
3132// When the repeatStr function is called with these inputs,
3233// Then it should throw an error, as negative counts are not valid.
34+ test ( "should throw and error when count is a negative number" , ( ) => {
35+ expect ( ( ) => repeatStr ( "Love" , - 3 ) ) . toThrow ( "Negative counts are not valid" ) ;
36+ } ) ;
0 commit comments