From 39c4257469fcf68073cccfd4f71b6d481c23539a Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Fri, 23 Aug 2013 14:20:07 +0200 Subject: [PATCH] double async check --- test/spec/async.spec.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/spec/async.spec.js b/test/spec/async.spec.js index 8aa5bd5..8c84ea8 100644 --- a/test/spec/async.spec.js +++ b/test/spec/async.spec.js @@ -9,7 +9,7 @@ describe("Asynchronous check", function () { }); // Asynchronous part - it("check running search", function () { + it("simple check", function () { var max_time = 1; var timer = 0; @@ -37,6 +37,47 @@ describe("Asynchronous check", function () { runs(function () { expect(timer).toEqual(max_time); }); + }); + + + it("double async check", function () { + var max_time = 0.5; + var timer = 0; + + function found(time, none) { + setTimeout(function () { + timer = time; + }, time * 1000); + } + + runs(function () { + found(0); + found(0.2); + found(max_time - 0.1); + }); + + waitsFor(function () { + return timer == max_time - 0.1 ? true : false; + }, "The Value should be N seconds", max_time * 1000); + + runs(function () { + expect(timer <= max_time).toBeTruthy(); + }); + + timer = 0; + runs(function () { + found(0.1); + found(max_time); + }); + waitsFor(function () { + // console.log("waits for ... " + timer); + return timer == max_time ? true : false; + }, "The Value should be N seconds", max_time * 1000); + + runs(function () { + expect(timer <= max_time).toBeTruthy(); + }); }); + }); -- 1.7.10.4