@@ -20,19 +20,19 @@ test("should repeat the string count times", () => {
2020// Given a target string str and a count equal to 1,
2121// When the repeat function is called with these inputs,
2222// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.
23- test ( "should return the original string when count is 1" , ( ) => {
24- const str = "hi " ;
23+ test ( "handle Count of 1" , ( ) => {
24+ const str = "hello " ;
2525 const count = 1 ;
2626 const repeatedStr = repeat ( str , count ) ;
27- expect ( repeatedStr ) . toEqual ( "hi " ) ;
27+ expect ( repeatedStr ) . toEqual ( "hello " ) ;
2828} ) ;
2929
3030// case: Handle Count of 0:
3131// Given a target string str and a count equal to 0,
3232// When the repeat function is called with these inputs,
3333// Then it should return an empty string, ensuring that a count of 0 results in an empty output.
34- test ( "should return an empty string when count is 0" , ( ) => {
35- const str = "test " ;
34+ test ( "handle Count of 0" , ( ) => {
35+ const str = "hello " ;
3636 const count = 0 ;
3737 const repeatedStr = repeat ( str , count ) ;
3838 expect ( repeatedStr ) . toEqual ( "" ) ;
@@ -42,10 +42,9 @@ test("should return an empty string when count is 0", () => {
4242// Given a target string str and a negative integer count,
4343// When the repeat function is called with these inputs,
4444// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
45- test ( "should throw an error when count is negative" , ( ) => {
46- const str = "error" ;
47- const count = - 2 ;
48- expect ( ( ) => repeat ( str , count ) ) . toThrow (
49- "Count must be a non-negative number"
50- ) ;
51- } ) ;
45+ test ( "Negative Count" , ( ) => {
46+ const str = "hello" ;
47+ const count = - 1 ;
48+ const repeatedStr = repeat ( str , count ) ;
49+ expect ( repeatedStr ) . toEqual ( null ) ;
50+ } ) ;
0 commit comments