@@ -63,45 +63,47 @@ test("should return 0 when the 'c' does not exist in string 'I dont have an appl
6363// When the function is called,
6464// Then it should return 0 because a multi-character string cannot match a single character position.
6565
66- test ( "should return 0 when findCharacter is longer than the input string" , ( ) => {
66+ test ( "should return a message when findCharacter is longer than the input string" , ( ) => {
6767 const str = "a" ;
6868 const char = "abc" ;
6969 const count = countChar ( str , char ) ;
70- expect ( count ) . toEqual ( 0 ) ;
70+ expect ( count ) . toEqual (
71+ "the stringOfCharacters MUST be lonegr than findingcharacter"
72+ ) ;
7173} ) ;
7274
7375// Scenario: Empty string input
7476// Given an empty input string and a valid character,
7577// When the function is called,
7678// Then it should return 0 because there are no characters to search.
7779
78- test ( "should return 0 when input string is empty" , ( ) => {
80+ test ( "should return a Message when input stringOfCharacters is empty" , ( ) => {
7981 const str = "" ;
8082 const char = "a" ;
8183 const count = countChar ( str , char ) ;
82- expect ( count ) . toEqual ( 0 ) ;
83- } ) ;
84-
85- // Scenario: Non-string input type
86- // Given that one or both inputs are not strings (e.g., number, array),
87- // When the function is called,
88- // Then it should return 0 or handle the input gracefully without throwing an error.
89-
90- test ( "should return 0 when inputs are not strings" , ( ) => {
91- const str = 12345 ;
92- const char = 1 ;
93- const count = countChar ( str , char ) ;
94- expect ( count ) . toEqual ( 0 ) ;
84+ expect ( count ) . toEqual ( "stringOfCharacters can not be empty" ) ;
9585} ) ;
9686
9787// Scenario: Empty findCharacter
9888// Given a valid string but an empty findCharacter,
9989// When the function is called,
10090// Then it should return 0 because an empty search target is not valid.
10191
102- test ( "should return 0 when findCharacter is an empty string" , ( ) => {
92+ test ( "should return message when findCharacter is an empty string" , ( ) => {
10393 const str = "hello" ;
10494 const char = "" ;
10595 const count = countChar ( str , char ) ;
106- expect ( count ) . toEqual ( 0 ) ;
96+ expect ( count ) . toEqual ( "findCharacter can not be empty" ) ;
97+ } ) ;
98+
99+ // Scenario: Non-string input type
100+ // Given that one or both inputs are not strings (e.g., number, array),
101+ // When the function is called,
102+ // Then it should return 0 or handle the input gracefully without throwing an error.
103+
104+ test ( "should return message when inputs are numbers" , ( ) => {
105+ const str = 12345 ;
106+ const char = 1 ;
107+ const count = countChar ( str , char ) ;
108+ expect ( count ) . toEqual ( "Values Can not be Numbers" ) ;
107109} ) ;
0 commit comments