| Total Complexity | 11 |
| Complexity/F | 1.22 |
| Lines of Code | 39 |
| Function Count | 9 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | /* eslint-env mocha */ |
||
| 3 | var Sinon = require('sinon') |
||
| 4 | var Chai = require('chai') |
||
| 5 | var expect = Chai.expect |
||
| 6 | var delay = require('../../../../lib').Concurrent.delay |
||
| 7 | |||
| 8 | describe('Integration', function () { |
||
| 9 | describe('/concurrent', function () { |
||
| 10 | describe('/timeout.js', function () { |
||
| 11 | describe('.delay', function () { |
||
| 12 | var clock |
||
| 13 | |||
| 14 | beforeEach(function () { |
||
| 15 | clock = Sinon.useFakeTimers() |
||
| 16 | }) |
||
| 17 | |||
| 18 | afterEach(function () { |
||
| 19 | clock.restore() |
||
| 20 | }) |
||
| 21 | |||
| 22 | it('delays processing of specified code', function () { |
||
| 23 | var callback = Sinon.stub() |
||
| 24 | var delayed = delay(10, callback) |
||
| 25 | expect(callback.callCount).to.eq(0) |
||
| 26 | clock.next() |
||
| 27 | return delayed |
||
| 28 | .then(function () { |
||
| 29 | expect(callback.callCount).to.eq(1) |
||
| 30 | }) |
||
| 31 | }) |
||
| 32 | |||
| 33 | it('creates delayed promise if no callback is specified', function () { |
||
| 34 | var promise = delay(1) |
||
| 35 | clock.next() |
||
| 36 | return promise |
||
| 37 | }) |
||
| 38 | }) |
||
| 39 | }) |
||
| 40 | }) |
||
| 41 | }) |
||
| 42 |