@@ -26,7 +26,13 @@ const MOCK_IP1_DATA = {
2626 company : { name : 'Cloudflare, Inc.' , domain : 'cloudflare.com' , network : '1.1.1.0/24' , type : 'hosting' } ,
2727 languages : [ { name : 'English' , native : 'English' , code : 'en' } ] ,
2828 currency : { name : 'US Dollar' , code : 'USD' , symbol : '$' , native : '$' , plural : 'US dollars' } ,
29- time_zone : { name : 'America/Los_Angeles' , abbr : 'PST' , offset : '-0800' , is_dst : false , current_time : '2024-01-01T00:00:00-08:00' } ,
29+ time_zone : {
30+ name : 'America/Los_Angeles' ,
31+ abbr : 'PST' ,
32+ offset : '-0800' ,
33+ is_dst : false ,
34+ current_time : '2024-01-01T00:00:00-08:00' ,
35+ } ,
3036 threat : {
3137 is_tor : false ,
3238 is_proxy : false ,
@@ -85,7 +91,7 @@ describe('constructor()', () => {
8591
8692 it ( 'should configure the cache by default' , ( ) => {
8793 const ipdata = new IPData ( TEST_API_KEY ) ;
88- expect ( ipdata . cache . max ) . toEqual ( 4096 ) ;
94+ expect ( ipdata . cache . max ) . toBe ( 4096 ) ;
8995 expect ( ipdata . cache . ttl ) . toEqual ( 1000 * 60 * 60 * 24 ) ;
9096 } ) ;
9197
@@ -99,12 +105,12 @@ describe('constructor()', () => {
99105
100106 it ( 'should use the default base URL' , ( ) => {
101107 const ipdata = new IPData ( TEST_API_KEY ) ;
102- expect ( ipdata . baseUrl ) . toEqual ( 'https://api.ipdata.co/' ) ;
108+ expect ( ipdata . baseUrl ) . toBe ( 'https://api.ipdata.co/' ) ;
103109 } ) ;
104110
105111 it ( 'should accept a custom base URL' , ( ) => {
106112 const ipdata = new IPData ( TEST_API_KEY , undefined , EU_BASE_URL ) ;
107- expect ( ipdata . baseUrl ) . toEqual ( 'https://eu-api.ipdata.co/' ) ;
113+ expect ( ipdata . baseUrl ) . toBe ( 'https://eu-api.ipdata.co/' ) ;
108114 } ) ;
109115} ) ;
110116
@@ -192,7 +198,7 @@ describe('lookup()', () => {
192198 } ) ;
193199
194200 describe ( 'selectField' , ( ) => {
195- it ( 'should throw an error for an invlaid field ' , async ( ) => {
201+ it ( 'should throw an error for an invlaid field' , async ( ) => {
196202 const field = 'field' ;
197203 await expect ( ipdata . lookup ( undefined , field ) ) . rejects . toThrow ( `${ field } is not a valid field.` ) ;
198204 } ) ;
@@ -207,7 +213,7 @@ describe('lookup()', () => {
207213 } ) ;
208214
209215 describe ( 'fields' , ( ) => {
210- it ( 'should throw an error for an invlaid field ' , async ( ) => {
216+ it ( 'should throw an error for an invlaid field' , async ( ) => {
211217 const field = 'field' ;
212218 const fields = [ field ] ;
213219 await expect ( ipdata . lookup ( undefined , undefined , fields ) ) . rejects . toThrow ( `${ field } is not a valid field.` ) ;
@@ -227,7 +233,12 @@ describe('lookup()', () => {
227233
228234 describe ( 'company field' , ( ) => {
229235 it ( 'should accept company as a valid select field' , async ( ) => {
230- const companyData = { name : 'Cloudflare, Inc.' , domain : 'cloudflare.com' , network : '1.1.1.0/24' , type : 'hosting' } ;
236+ const companyData = {
237+ name : 'Cloudflare, Inc.' ,
238+ domain : 'cloudflare.com' ,
239+ network : '1.1.1.0/24' ,
240+ type : 'hosting' ,
241+ } ;
231242 mockFetch . mockReturnValueOnce ( mockFetchResponse ( companyData ) ) ;
232243 const info = await ipdata . lookup ( TEST_IP , 'company' ) ;
233244 expect ( info ) . toHaveProperty ( 'company' ) ;
@@ -308,7 +319,7 @@ describe('bulkLookup()', () => {
308319 const IP3 = '1.0.0.1' ;
309320 mockFetch . mockReturnValueOnce ( mockFetchResponse ( MOCK_IP1_DATA ) ) ;
310321 await ipdata . lookup ( IP1 ) ;
311- expect ( ipdata . cache . get ( IP1 ) ) . not . toBeUndefined ( ) ;
322+ expect ( ipdata . cache . get ( IP1 ) ) . toBeDefined ( ) ;
312323 mockFetch . mockReturnValueOnce ( mockFetchResponse ( [ MOCK_IP2_DATA , MOCK_IP3_DATA ] ) ) ;
313324 const result = await ipdata . bulkLookup ( [ IP1 , IP2 , IP3 ] ) ;
314325 const info = keyBy ( result ) ;
@@ -321,7 +332,7 @@ describe('bulkLookup()', () => {
321332 } ) ;
322333
323334 describe ( 'fields' , ( ) => {
324- it ( 'should throw an error for an invlaid field ' , async ( ) => {
335+ it ( 'should throw an error for an invlaid field' , async ( ) => {
325336 const field = 'field' ;
326337 const fields = [ field ] ;
327338 await expect ( ipdata . bulkLookup ( [ IP1 , IP2 ] , fields ) ) . rejects . toThrow ( `${ field } is not a valid field.` ) ;
@@ -331,10 +342,12 @@ describe('bulkLookup()', () => {
331342 const field1 = 'ip' ;
332343 const field2 = 'is_eu' ;
333344 const fields = [ field1 , field2 ] ;
334- mockFetch . mockReturnValueOnce ( mockFetchResponse ( [
335- { ip : IP1 , is_eu : false } ,
336- { ip : IP2 , is_eu : true } ,
337- ] ) ) ;
345+ mockFetch . mockReturnValueOnce (
346+ mockFetchResponse ( [
347+ { ip : IP1 , is_eu : false } ,
348+ { ip : IP2 , is_eu : true } ,
349+ ] ) ,
350+ ) ;
338351 const result = await ipdata . bulkLookup ( [ IP1 , IP2 ] , fields ) ;
339352 const info = keyBy ( result ) ;
340353 expect ( info [ IP1 ] ) . toHaveProperty ( field1 , IP1 ) ;
0 commit comments