mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
http with worker test added (#3467)
* test added * http with worker test added * file deleted
This commit is contained in:
10
tests/app/http-string-worker.ts
Normal file
10
tests/app/http-string-worker.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
require("globals");
|
||||
import http = require("http");
|
||||
|
||||
declare var postMessage : any;
|
||||
|
||||
http.getString("https://httpbin.org/get").then(function (r) {
|
||||
postMessage(r);
|
||||
}, function (e) {
|
||||
throw e;
|
||||
});
|
||||
@@ -511,12 +511,12 @@ export var test_request_headersWithSameKeyAddedProperly = function (done) {
|
||||
var keyName = "key";
|
||||
var value1 = "value1";
|
||||
var value2 = "value2";
|
||||
|
||||
|
||||
var headers = {};
|
||||
|
||||
|
||||
(<any>http).addHeader(headers, keyName, value1);
|
||||
(<any>http).addHeader(headers, keyName, value2);
|
||||
|
||||
|
||||
try {
|
||||
TKUnit.assertTrue(Array.isArray(headers[keyName]));
|
||||
TKUnit.assertEqual(headers[keyName][0], value1);
|
||||
@@ -629,4 +629,23 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
|
||||
// console.log("Error occurred " + e);
|
||||
});
|
||||
// << http-post-json
|
||||
};
|
||||
};
|
||||
|
||||
declare var Worker: any;
|
||||
export var test_getString_WorksProperlyInWorker = function () {
|
||||
var ready;
|
||||
|
||||
var worker = new Worker("./http-string-worker");
|
||||
|
||||
worker.onmessage = function (msg) {
|
||||
TKUnit.assert(typeof msg.data === "string", "Result from getString() should be valid string object!");
|
||||
ready = true;
|
||||
}
|
||||
|
||||
worker.onerror = function (e) {
|
||||
ready = true;
|
||||
throw e;
|
||||
}
|
||||
|
||||
TKUnit.waitUntilReady(() => ready);
|
||||
}
|
||||
Reference in New Issue
Block a user