async check
[mkws-moved-to-github.git] / test / spec / async.spec.js
1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
2  *
3  * async check
4  *
5  */
6 describe("Asynchronous check", function () {
7     it("contains spec with an expectation", function () {
8         expect(true).toBe(true);
9     });
10
11     // Asynchronous part
12     it("check running search", function () {
13         var max_time = 1;
14         var timer = 0;
15
16         function found(time, none) {
17             setTimeout(function () {
18                 timer = time;
19             }, time * 1000);
20         }
21
22         runs(function () {
23             // check hit counter after N seconds
24             found(0, true);
25             found(0.2);
26             found(0.4);
27             found(0.5);
28             found(0.7);
29             found(max_time);
30         });
31
32         waitsFor(function () {
33             // console.log("waits for ... " + timer);
34             return timer == max_time ? true : false;
35         }, "The Value should be N seconds", max_time * 1000);
36
37         runs(function () {
38             expect(timer).toEqual(max_time);
39         });
40
41     });
42 });