Add the example

This commit is contained in:
Erjan Gavalji
2015-04-06 11:48:24 +03:00
parent 3ed3469377
commit edf4bd521e

View File

@@ -364,6 +364,9 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done
};
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
// <snippet module="http" title="http">
// ### 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();
// <hide>
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);
}
// </hide>
// console.log(result);
}, function (e) {
// <hide>
done(e);
// </hide>
// console.log("Error occurred " + e);
});
// ```
// </snippet>
};
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" }));
};
};