(fn, timeout, callback, start)
| 18 | // retries the assertion until it passes or the timeout is reached, |
| 19 | // at which point it throws the assertion error |
| 20 | var waitFor = function (fn, timeout, callback, start) { |
| 21 | start = start || new Date().getTime(); |
| 22 | callback = callback || function () {}; |
| 23 | try { |
| 24 | fn(); |
| 25 | callback(); |
| 26 | } |
| 27 | catch (e) { |
| 28 | if (e instanceof assert.AssertionError) { |
| 29 | var now = new Date().getTime(); |
| 30 | if (now - start >= timeout) { |
| 31 | throw e; |
| 32 | } |
| 33 | else { |
| 34 | async.nextTick(function () { |
| 35 | waitFor(fn, timeout, callback, start); |
| 36 | }); |
| 37 | } |
| 38 | } |
| 39 | else { |
| 40 | throw e; |
| 41 | } |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | // TESTS: |
no test coverage detected
searching dependent graphs…