From edf4bd521e1defebb14a3c0d8b176754108469c0 Mon Sep 17 00:00:00 2001 From: Erjan Gavalji Date: Mon, 6 Apr 2015 11:48:24 +0300 Subject: [PATCH 1/2] Add the example --- apps/tests/http-tests.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/tests/http-tests.ts b/apps/tests/http-tests.ts index 53a3711d8..4e9678e3f 100644 --- a/apps/tests/http-tests.ts +++ b/apps/tests/http-tests.ts @@ -364,6 +364,9 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done }; export var test_request_jsonAsContentSentAndReceivedProperly = function (done) { + // + // ### Post JSON + // ``` JavaScript var result; http.request({ @@ -372,6 +375,7 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) { content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" }) }).then(function (response) { result = response.content.toJSON(); + // try { TKUnit.assert(result["json"]["MyVariableOne"] === "ValueOne" && result["json"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!"); done(null); @@ -379,9 +383,16 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) { catch (err) { done(err); } + // + // console.log(result); }, function (e) { + // done(e); + // + // console.log("Error occurred " + e); }); + // ``` + // }; export var test_getString_FromVariousUrls_ShouldWorkProperly = function (done) { @@ -554,4 +565,4 @@ export var test_XMLHttpRequest_requestShouldBePossibleAfterAbort = function (don xhr.abort(); xhr.send(JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" })); -}; \ No newline at end of file +}; From f59f8858243d4b8a0ca7beeb2af5b99a6777db6d Mon Sep 17 00:00:00 2001 From: Erjan Gavalji Date: Tue, 28 Apr 2015 14:29:15 +0300 Subject: [PATCH 2/2] Cheat the TypeScript compilse that removed the tag before the try-catch block --- apps/tests/http-tests.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/tests/http-tests.ts b/apps/tests/http-tests.ts index 4e9678e3f..a3c0dd905 100644 --- a/apps/tests/http-tests.ts +++ b/apps/tests/http-tests.ts @@ -374,9 +374,11 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) { headers: { "Content-Type": "application/json" }, content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" }) }).then(function (response) { + // result = response.content.toJSON(); + // result = response.content.toJSON(); - // - try { + try + { TKUnit.assert(result["json"]["MyVariableOne"] === "ValueOne" && result["json"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!"); done(null); }