File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,25 @@ 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 when count is 1" , ( ) => {
25+ expect ( repeatStr ( "hello" , 1 ) ) . toEqual ( "hello" ) ;
26+ } ) ;
27+
2428// Case: Handle count of 0:
2529// Given a target string `str` and a `count` equal to 0,
2630// When the repeatStr function is called with these inputs,
2731// Then it should return an empty string.
2832
33+ test ( "should return an empty string when count is 0" , ( ) => {
34+ expect ( repeatStr ( "hello" , 0 ) ) . toEqual ( "" ) ;
35+ } ) ;
36+
2937// Case: Handle negative count:
3038// Given a target string `str` and a negative integer `count`,
3139// When the repeatStr function is called with these inputs,
3240// Then it should throw an error, as negative counts are not valid.
41+
42+
43+ test ( "should throw an error when count is negative" , ( ) => {
44+ expect ( ( ) => repeatStr ( "hello" , - 1 ) ) . toThrow ( ) ;
45+ } ) ;
You can’t perform that action at this time.
0 commit comments