From 5cb2af29b1eebdf8b8f656c397220baa587f6c3a Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Thu, 15 May 2014 10:50:33 +0300 Subject: [PATCH] readme updated and one test made async --- Tests/Readme.md | 2 ++ Tests/http-tests.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Tests/Readme.md b/Tests/Readme.md index de5e8c021..925fe6a46 100644 --- a/Tests/Readme.md +++ b/Tests/Readme.md @@ -2,6 +2,8 @@ ##iOS ```js +var app = require("application"); +app.init(null); var tests = require("Tests"); tests.runAll(); ``` diff --git a/Tests/http-tests.ts b/Tests/http-tests.ts index 7dc7c8ef9..f74d5fa3b 100644 --- a/Tests/http-tests.ts +++ b/Tests/http-tests.ts @@ -1,15 +1,24 @@ import TKUnit = require("Tests/TKUnit"); import http = require("http/http"); import http_request = require("http/http-request"); +require("globals"); export var test_getString_isDefined = function () { TKUnit.assert(typeof (http.getString) !== "undefined", "Method http.getString() should be defined!"); }; export var test_getString = function () { - http.getString("http://httpbin.org/get").then(function (result) { - TKUnit.assert(typeof (result) === "string", "Result from getString() should be string!"); - }); + var result; + var completed: boolean; + var isReady = function () { return completed; } + + http.getString("http://httpbin.org/get").then(function (r) { + completed = true; + result = r; + }).fail(function (e) { console.log(e); }); + + TKUnit.waitUntilReady(isReady, 3); + TKUnit.assert(typeof (result) === "string", "Result from getString() should be string!"); }; export var test_getString_fail = function () {