@@ -52,6 +52,37 @@ describe("Call test endpoint", () => {
5252 && expect ( obj . hiddengames [ 0 ] ) . to . equal ( "Tic-Tac-Toe" )
5353 } )
5454
55+ it ( 'Headers were passed along' , async ( ) => {
56+
57+ let headers = {
58+ Authorization : "Basic somerandomExampleKey" ,
59+ 'if-none-match' : "528cd81ca4" ,
60+ 'if-modified-since' : "Mon, 14 Feb 2022 03:44:00 GMT" ,
61+ 'x-my-custom-header' : "hello world"
62+ } ;
63+ let req = new tools . APIRequest ( {
64+ method : "POST" ,
65+ host : "labkit.api.63klabs.net" ,
66+ path : "/echo/" ,
67+ headers : headers ,
68+ uri : "" ,
69+ protocol : "https" ,
70+ body : null ,
71+ parameters : { }
72+ } )
73+ const result = await req . send ( )
74+ const obj = JSON . parse ( result . body ) ;
75+
76+ expect ( result . statusCode ) . to . equal ( 200 )
77+ && expect ( result . success ) . to . equal ( true )
78+ && expect ( ( typeof result . headers ) ) . to . equal ( 'object' )
79+ && expect ( result . message ) . to . equal ( "SUCCESS" )
80+ && expect ( obj . headers . Authorization ) . to . equal ( headers . Authorization )
81+ && expect ( obj . headers [ 'if-none-match' ] ) . to . equal ( headers [ 'if-none-match' ] )
82+ && expect ( obj . headers [ 'if-modified-since' ] ) . to . equal ( headers [ 'if-modified-since' ] )
83+ && expect ( obj . headers [ 'x-my-custom-header' ] ) . to . equal ( headers [ 'x-my-custom-header' ] )
84+ } ) ;
85+
5586 it ( 'Passing host and path and an empty uri results in success with a hidden game listed' , async ( ) => {
5687 let req = new tools . APIRequest ( { host : 'api.chadkluck.net' , path : '/games/' , uri : '' } )
5788 const result = await req . send ( )
0 commit comments