File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,29 @@ test("should return 0 when the input string is empty", () => {
4747test ( "should count special characters like spaces or punctuation" , ( ) => {
4848 const str1 = "a b a b" ;
4949 const char1 = " " ;
50- expect ( countChar ( str1 , char1 ) ) . toEqual ( 2 ) ;
50+ expect ( countChar ( str1 , char1 ) ) . toEqual ( 3 ) ;
5151
5252 const str2 = "NO !!!" ;
5353 const char2 = "!" ;
5454 expect ( countChar ( str2 , char2 ) ) . toEqual ( 3 ) ;
5555} ) ;
5656
57+ // Scenario: Numeric characters inside string
58+
59+ test ( "should count numeric characters inside the string" , ( ) => {
60+ const str3 = "123321" ;
61+ const char3 = "2" ;
62+ expect ( countChar ( str3 , char3 ) ) . toEqual ( 2 ) ;
63+ } ) ;
64+
65+ // Scenarion Accented characters
66+
67+ test ( "should count accented characters and unicode properly" , ( ) => {
68+ const str4 = "café" ;
69+ const char4 = "é" ;
70+ expect ( countChar ( str4 , char4 ) ) . toEqual ( 1 ) ;
71+ } ) ;
72+
5773// Scenario: Invalid inputs
5874
5975test ( "should throw error for invalid string input" , ( ) => {
@@ -65,4 +81,6 @@ test("should throw error for invalid character input", () => {
6581} ) ;
6682
6783
68- // Added different cases and test using npx jest
84+ // Added different cases and test using npx jest
85+
86+ // Added some tests, additional test and passed the tests.
You can’t perform that action at this time.
0 commit comments