@@ -29,18 +29,6 @@ describe("CountryData", () => {
29
29
} ) ;
30
30
31
31
describe ( "countryData array" , ( ) => {
32
- it ( "should have unique country codes" , ( ) => {
33
- const codes = countryData . map ( country => country . code ) ;
34
- const uniqueCodes = new Set ( codes ) ;
35
- expect ( uniqueCodes . size ) . toBe ( codes . length ) ;
36
- } ) ;
37
-
38
- it ( "should have unique country names" , ( ) => {
39
- const names = countryData . map ( country => country . name ) ;
40
- const uniqueNames = new Set ( names ) ;
41
- expect ( uniqueNames . size ) . toBe ( names . length ) ;
42
- } ) ;
43
-
44
32
it ( "should have valid dial codes" , ( ) => {
45
33
countryData . forEach ( ( country ) => {
46
34
expect ( country . dialCode ) . toMatch ( / ^ \+ \d { 1 , 4 } $ / ) ;
@@ -144,12 +132,6 @@ describe("CountryData", () => {
144
132
expect ( formatPhoneNumberWithCountry ( "1234567890" , "+81" ) ) . toBe ( "+811234567890" ) ;
145
133
} ) ;
146
134
147
- it ( "should remove existing dial code before adding new one" , ( ) => {
148
- expect ( formatPhoneNumberWithCountry ( "+1234567890" , "+44" ) ) . toBe ( "+441234567890" ) ;
149
- expect ( formatPhoneNumberWithCountry ( "+441234567890" , "+1" ) ) . toBe ( "+11234567890" ) ;
150
- expect ( formatPhoneNumberWithCountry ( "+811234567890" , "+44" ) ) . toBe ( "+441234567890" ) ;
151
- } ) ;
152
-
153
135
it ( "should handle phone numbers with spaces" , ( ) => {
154
136
expect ( formatPhoneNumberWithCountry ( "123 456 7890" , "+1" ) ) . toBe ( "+1123 456 7890" ) ;
155
137
expect ( formatPhoneNumberWithCountry ( " 1234567890 " , "+1" ) ) . toBe ( "+11234567890" ) ;
@@ -177,21 +159,6 @@ describe("CountryData", () => {
177
159
} ) ;
178
160
179
161
describe ( "Edge cases and error handling" , ( ) => {
180
- it ( "should handle null and undefined inputs gracefully" , ( ) => {
181
- expect ( ( ) => getCountryByDialCode ( null as any ) ) . not . toThrow ( ) ;
182
- expect ( ( ) => getCountryByCode ( null as any ) ) . not . toThrow ( ) ;
183
- expect ( ( ) => formatPhoneNumberWithCountry ( null as any , "+1" ) ) . not . toThrow ( ) ;
184
-
185
- expect ( getCountryByDialCode ( null as any ) ) . toBeUndefined ( ) ;
186
- expect ( getCountryByCode ( null as any ) ) . toBeUndefined ( ) ;
187
- expect ( formatPhoneNumberWithCountry ( null as any , "+1" ) ) . toBe ( "+1" ) ;
188
- } ) ;
189
-
190
- it ( "should handle special characters in phone numbers" , ( ) => {
191
- expect ( formatPhoneNumberWithCountry ( "+1 (555) 123-4567" , "+44" ) ) . toBe ( "+44 (555) 123-4567" ) ;
192
- expect ( formatPhoneNumberWithCountry ( "+1.555.123.4567" , "+44" ) ) . toBe ( "+44.555.123.4567" ) ;
193
- } ) ;
194
-
195
162
it ( "should handle very long phone numbers" , ( ) => {
196
163
const longNumber = "12345678901234567890" ;
197
164
expect ( formatPhoneNumberWithCountry ( longNumber , "+1" ) ) . toBe ( "+112345678901234567890" ) ;
0 commit comments