Completed
Push — dev ( d30456...4fd03f )
by Fike
33s
created

test/suites/integration/concurrent/timeout.delay.spec.js   A

Complexity

Total Complexity 11
Complexity/F 1.22

Size

Lines of Code 39
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 39
rs 10
wmc 11
mnd 0
bc 9
fnc 9
bpm 1
cpm 1.2222
noi 0
1
/* eslint-env mocha */
2
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