File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,17 @@ const API_KEY = process.env.IPREGISTRY_API_KEY || 'tryou';
3131const API_KEY_THROTTLED = process . env . IPREGISTRY_API_KEY_THROTTLED || 'tryout' ;
3232
3333describe ( 'lookup' , ( ) => {
34+ it ( 'should throw ApiError when input IP is reserved' , async ( ) => {
35+ try {
36+ const client = new IpregistryClient ( API_KEY ) ;
37+ await client . lookup ( '0.1.2.3' ) ;
38+ expect . fail ( ) ;
39+ } catch ( error : any ) {
40+ expect ( error ) . to . be . instanceOf ( ApiError ) ;
41+ expect ( error . code ) . equal ( 'RESERVED_IP_ADDRESS' ) ;
42+ }
43+ } ) ;
44+
3445 it ( 'should return valid information when IPv4 address is known' , async ( ) => {
3546 const client = new IpregistryClient ( API_KEY ) ;
3647 const response = await client . lookup ( '8.8.8.8' ) ;
@@ -69,6 +80,9 @@ describe('lookup', () => {
6980 const response = await client . lookup ( '8.8.8.8' , IpregistryOptions . hostname ( true ) ) ;
7081 const ipInfo = response . data ;
7182 expect ( ipInfo . type ) . equal ( 'IPv4' ) ;
83+ expect ( ipInfo . company . domain ) . not . null ;
84+ expect ( ipInfo . company . name ) . not . null ;
85+ expect ( ipInfo . company . type ) . not . null ;
7286 expect ( ipInfo . location . country . code ) . equal ( 'US' ) ;
7387 expect ( ipInfo . hostname ) . not . null ;
7488 } ) ;
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ export interface IpInfo {
2424
2525 carrier : Carrier ;
2626
27+ company : Company ;
28+
2729 connection : Connection ;
2830
2931 currency : Currency ;
@@ -104,6 +106,16 @@ export interface Carrier {
104106
105107}
106108
109+ export interface Company {
110+
111+ domain : string | null ;
112+
113+ name : string | null ;
114+
115+ type : 'business' | 'education' | 'government' | 'isp' | 'hosting' | null ;
116+
117+ }
118+
107119export interface Connection {
108120
109121 asn : number | null ;
@@ -114,7 +126,7 @@ export interface Connection {
114126
115127 route : string | null ;
116128
117- type : 'business' | 'education' | 'government' | 'isp' | 'hosting' | null ;
129+ type : 'business' | 'education' | 'government' | 'inactive' | ' isp' | 'hosting' | null ;
118130
119131}
120132
You can’t perform that action at this time.
0 commit comments