File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -364,24 +364,37 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done
364
364
} ;
365
365
366
366
export var test_request_jsonAsContentSentAndReceivedProperly = function ( done ) {
367
+ // <snippet module="http" title="http">
368
+ // ### Post JSON
369
+ // ``` JavaScript
367
370
var result ;
368
371
369
372
http . request ( {
370
373
url : "https://httpbin.org/post" , method : "POST" ,
371
374
headers : { "Content-Type" : "application/json" } ,
372
375
content : JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } )
373
376
} ) . then ( function ( response ) {
377
+ // result = response.content.toJSON();
378
+ // <hide>
374
379
result = response . content . toJSON ( ) ;
375
- try {
380
+ try
381
+ {
376
382
TKUnit . assert ( result [ "json" ] [ "MyVariableOne" ] === "ValueOne" && result [ "json" ] [ "MyVariableTwo" ] === "ValueTwo" , "Content not sent/received properly!" ) ;
377
383
done ( null ) ;
378
384
}
379
385
catch ( err ) {
380
386
done ( err ) ;
381
387
}
388
+ // </hide>
389
+ // console.log(result);
382
390
} , function ( e ) {
391
+ // <hide>
383
392
done ( e ) ;
393
+ // </hide>
394
+ // console.log("Error occurred " + e);
384
395
} ) ;
396
+ // ```
397
+ // </snippet>
385
398
} ;
386
399
387
400
export var test_getString_FromVariousUrls_ShouldWorkProperly = function ( done ) {
@@ -554,4 +567,4 @@ export var test_XMLHttpRequest_requestShouldBePossibleAfterAbort = function (don
554
567
xhr . abort ( ) ;
555
568
556
569
xhr . send ( JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } ) ) ;
557
- } ;
570
+ } ;
You can’t perform that action at this time.
0 commit comments