X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fspec%2Fasync.spec.js;h=dc09ceb4324380c36a30557bdfab6c9b03992dc4;hb=bb5b00d30080c9f6d55d7726e9f5264800d1e61e;hp=8aa5bd5a9b16df0f2f720ce2c0b69485af39be40;hpb=d037c0c8007d58ce933533c99e7f29293e5bb64d;p=mkws-moved-to-github.git diff --git a/test/spec/async.spec.js b/test/spec/async.spec.js index 8aa5bd5..dc09ceb 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; @@ -17,6 +17,7 @@ describe("Asynchronous check", function () { setTimeout(function () { timer = time; }, time * 1000); + expect(time >= 0).toBeTruthy(); } runs(function () { @@ -37,6 +38,48 @@ 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); + expect(time >= 0).toBeTruthy(); + } + + 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(); + }); }); + });