File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 77 TIMEOUT ,
88 STRICT_AUTHORISATION ,
99} from "@ideal-postcodes/core-interface" ;
10- import { Agent } from "./agent" ;
10+ import { Agent , GotConfig } from "./agent" ;
1111
1212const userAgent = `IdealPostcodes ideal-postcodes/core-node` ;
1313
@@ -16,8 +16,8 @@ interface Config extends Partial<CoreConfig> {
1616}
1717
1818export class Client extends CoreInterface {
19- constructor ( config : Config ) {
20- const agent = new Agent ( ) ;
19+ constructor ( config : Config , gotConfig : GotConfig = { } ) {
20+ const agent = new Agent ( gotConfig ) ;
2121 const header = { "User-Agent" : userAgent } ;
2222 const tls = config . tls === undefined ? TLS : config . tls ;
2323 const baseUrl = config . baseUrl === undefined ? API_URL : config . baseUrl ;
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ describe("Client", () => {
2525 assert . equal ( client . strictAuthorisation , STRICT_AUTHORISATION ) ;
2626 assert . equal ( client . timeout , TIMEOUT ) ;
2727 } ) ;
28+
2829 it ( "allows default config values to be overwritten" , ( ) => {
2930 const options = {
3031 tls : false ,
@@ -44,9 +45,17 @@ describe("Client", () => {
4445 options . strictAuthorisation
4546 ) ;
4647 assert . equal ( customClient . timeout , options . timeout ) ;
48+ assert . deepEqual ( ( customClient . agent as any ) . gotConfig , { } ) ;
4749 } ) ;
50+
4851 it ( "assigns user agent header" , ( ) => {
4952 assert . match ( client . header [ "User-Agent" ] , / C o r e - N o d e / i) ;
5053 } ) ;
54+
55+ it ( "assigns got config" , ( ) => {
56+ const retry = 2 ;
57+ const customClient = new Client ( { api_key } , { retry } ) ;
58+ assert . deepEqual ( ( customClient . agent as any ) . gotConfig , { retry } ) ;
59+ } ) ;
5160 } ) ;
5261} ) ;
You can’t perform that action at this time.
0 commit comments