@@ -20,13 +20,23 @@ test("should repeat the string count times", () => {
2020// Given a target string `str` and a `count` equal to 1,
2121// When the repeatStr function is called with these inputs,
2222// Then it should return the original `str` without repetition.
23+ test ( "should repeat the string only once" , ( ) => {
24+ expect ( repeatStr ( "nihao" , 1 ) ) . toEqual ( "nihao" ) ;
25+ } ) ;
2326
2427// Case: Handle count of 0:
2528// Given a target string `str` and a `count` equal to 0,
2629// When the repeatStr function is called with these inputs,
2730// Then it should return an empty string.
31+ test ( "should repeat the string 0" , ( ) => {
32+ expect ( repeatStr ( "newyear" , 0 ) ) . toEqual ( "" ) ;
33+ } ) ;
2834
2935// Case: Handle negative count:
3036// Given a target string `str` and a negative integer `count`,
3137// When the repeatStr function is called with these inputs,
3238// Then it should throw an error, as negative counts are not valid.
39+ test ( "should throw an error when count is negative" , ( ) => {
40+ expect ( ( ) => repeatStr ( "celebration" , - 5 ) )
41+ . toThrow ( "Count cannot be negative" ) ;
42+ } ) ;
0 commit comments