@@ -23,33 +23,31 @@ describe('lookup (country)', () => {
2323 it ( 'should return the country for a valid IP address' , async ( { expect } ) => {
2424 //* Ipv4
2525 const result = await lookup ( '8.8.8.8' )
26- expect ( result ) . not . toBeNull ( )
27- expect ( result ) . toEqual ( { country : 'US' } )
26+ expect . soft ( result ) . not . toBeNull ( )
27+ expect . soft ( result ) . toEqual ( { country : 'US' } )
2828
2929 const result2 = await lookup ( '207.97.227.239' )
30- expect ( result2 ) . not . toBeNull ( )
31- expect ( result2 ) . toEqual ( { country : 'US' } )
30+ expect . soft ( result2 ) . not . toBeNull ( )
31+ expect . soft ( result2 ) . toEqual ( { country : 'US' } )
3232
3333 //* Ipv6
3434 const result3 = await lookup ( '2607:F8B0:4005:801::200E' )
35- expect ( result3 ) . not . toBeNull ( )
36- expect ( result3 ) . toEqual ( { country : 'US' } )
35+ expect . soft ( result3 ) . not . toBeNull ( )
36+ expect . soft ( result3 ) . toEqual ( { country : 'US' } )
3737
3838 //* Invalid IP address
39- await expect ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
39+ await expect . soft ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
4040
4141 //* Too high IP address
42- expect ( await lookup ( '256.256.256.256' ) ) . toBeNull ( )
42+ await expect . soft ( lookup ( '256.256.256.256' ) ) . resolves . toBeNull ( )
4343
4444 //* Clear data
4545 clear ( )
4646
4747 //* Ips should return null after data is cleared
48- const result4 = await lookup ( '8.8.8.8' )
49- expect ( result4 ) . toBeNull ( )
48+ await expect . soft ( lookup ( '8.8.8.8' ) ) . resolves . toBeNull ( )
5049
51- const result5 = await lookup ( '2607:F8B0:4005:801::200E' )
52- expect ( result5 ) . toBeNull ( )
50+ await expect . soft ( lookup ( '2607:F8B0:4005:801::200E' ) ) . resolves . toBeNull ( )
5351 } )
5452} )
5553
@@ -74,33 +72,31 @@ describe('lookup (country, smallMemory)', () => {
7472 it ( 'should return the country for a valid IP address' , async ( { expect } ) => {
7573 //* Ipv4
7674 const result = await lookup ( '8.8.8.8' )
77- expect ( result ) . not . toBeNull ( )
78- expect ( result ) . toEqual ( { country : 'US' } )
75+ expect . soft ( result ) . not . toBeNull ( )
76+ expect . soft ( result ) . toEqual ( { country : 'US' } )
7977
8078 const result2 = await lookup ( '207.97.227.239' )
81- expect ( result2 ) . not . toBeNull ( )
82- expect ( result2 ) . toEqual ( { country : 'US' } )
79+ expect . soft ( result2 ) . not . toBeNull ( )
80+ expect . soft ( result2 ) . toEqual ( { country : 'US' } )
8381
8482 //* Ipv6
8583 const result3 = await lookup ( '2607:F8B0:4005:801::200E' )
86- expect ( result3 ) . not . toBeNull ( )
87- expect ( result3 ) . toEqual ( { country : 'US' } )
84+ expect . soft ( result3 ) . not . toBeNull ( )
85+ expect . soft ( result3 ) . toEqual ( { country : 'US' } )
8886
8987 //* Invalid IP address
90- await expect ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
88+ await expect . soft ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
9189
9290 //* Too high IP address
93- expect ( await lookup ( '256.256.256.256' ) ) . toBeNull ( )
91+ await expect . soft ( lookup ( '256.256.256.256' ) ) . resolves . toBeNull ( )
9492
9593 //* Clear data
9694 clear ( )
9795
9896 //* Ips should return null after data is cleared
99- const result4 = await lookup ( '8.8.8.8' )
100- expect ( result4 ) . toBeNull ( )
97+ await expect . soft ( lookup ( '8.8.8.8' ) ) . resolves . toBeNull ( )
10198
102- const result5 = await lookup ( '2607:F8B0:4005:801::200E' )
103- expect ( result5 ) . toBeNull ( )
99+ await expect . soft ( lookup ( '2607:F8B0:4005:801::200E' ) ) . resolves . toBeNull ( )
104100 } )
105101} )
106102
@@ -124,13 +120,13 @@ describe('lookup (city)', () => {
124120 it ( 'should return the city and country for a valid IP address' , async ( { expect } ) => {
125121 //* Ipv4
126122 const result = await lookup ( '170.171.1.0' )
127- expect ( result ) . not . toBeNull ( )
128- expect ( result ) . toEqual ( { city : 'New York' , country : 'US' } )
123+ expect . soft ( result ) . not . toBeNull ( )
124+ expect . soft ( result ) . toEqual ( { city : 'New York' , country : 'US' } )
129125
130126 //* Ipv6
131127 const result2 = await lookup ( '2606:2e00:8003::216:3eff:fe82:68ab' )
132- expect ( result2 ) . not . toBeNull ( )
133- expect ( result2 ) . toEqual ( { city : 'New York' , country : 'US' } )
128+ expect . soft ( result2 ) . not . toBeNull ( )
129+ expect . soft ( result2 ) . toEqual ( { city : 'New York' , country : 'US' } )
134130 } )
135131} )
136132
@@ -156,8 +152,8 @@ describe('lookup (all, smallMemory)', () => {
156152 it ( 'should return all fields for a valid IP address' , async ( { expect } ) => {
157153 //* Ipv4 (Metro code)
158154 const result1 = await lookup ( '170.171.1.0' )
159- expect ( result1 ) . not . toBeNull ( )
160- expect ( result1 ) . toEqual ( {
155+ expect . soft ( result1 ) . not . toBeNull ( )
156+ expect . soft ( result1 ) . toEqual ( {
161157 area : 10 ,
162158 capital : 'Washington D.C.' ,
163159 city : 'New York' ,
@@ -189,8 +185,8 @@ describe('lookup (all, smallMemory)', () => {
189185
190186 //* Ipv4 (Region2)
191187 const result2 = await lookup ( '213.189.170.238' )
192- expect ( result2 ) . not . toBeNull ( )
193- expect ( result2 ) . toEqual ( {
188+ expect . soft ( result2 ) . not . toBeNull ( )
189+ expect . soft ( result2 ) . toEqual ( {
194190 area : 50 ,
195191 capital : 'Brussels' ,
196192 city : 'Charleroi' ,
@@ -238,14 +234,14 @@ describe('lookup (all, smallMemory)', () => {
238234
239235 for ( const { ip, postcode } of postalCodesTest ) {
240236 const result = await lookup ( ip )
241- expect ( result ) . not . toBeNull ( )
242- expect ( result ) . toMatchObject ( { postcode } )
237+ expect . soft ( result ) . not . toBeNull ( )
238+ expect . soft ( result ) . toMatchObject ( { postcode } )
243239 }
244240
245241 //* Ipv6
246242 const result4 = await lookup ( '2607:F8B0:4005:801::200E' )
247- expect ( result4 ) . not . toBeNull ( )
248- expect ( result4 ) . toEqual ( {
243+ expect . soft ( result4 ) . not . toBeNull ( )
244+ expect . soft ( result4 ) . toEqual ( {
249245 area : 1000 ,
250246 capital : 'Washington D.C.' ,
251247 continent : 'NA' ,
@@ -271,19 +267,17 @@ describe('lookup (all, smallMemory)', () => {
271267 } )
272268
273269 //* Invalid IP address
274- await expect ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
270+ await expect . soft ( lookup ( 'invalid' ) ) . rejects . toThrowError ( 'Invalid IPv4 address: invalid' )
275271
276272 //* Too high IP address
277- expect ( await lookup ( '256.256.256.256' ) ) . toBeNull ( )
273+ await expect . soft ( lookup ( '256.256.256.256' ) ) . resolves . toBeNull ( )
278274
279275 //* Clear data
280276 clear ( )
281277
282278 //* Ips should return null after data is cleared
283- const result5 = await lookup ( '8.8.8.8' )
284- expect ( result5 ) . toBeNull ( )
279+ await expect . soft ( lookup ( '8.8.8.8' ) ) . resolves . toBeNull ( )
285280
286- const result6 = await lookup ( '2607:F8B0:4005:801::200E' )
287- expect ( result6 ) . toBeNull ( )
281+ await expect . soft ( lookup ( '2607:F8B0:4005:801::200E' ) ) . resolves . toBeNull ( )
288282 } )
289283} )
0 commit comments