Completed
Push — dev ( 6ada4c...6e0845 )
by Fike
31s
created

test/suite/acceptance/Stub/VoxEngine.spec.js   A

Complexity

Total Complexity 14
Complexity/F 1.27

Size

Lines of Code 53
Function Count 11

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 53
rs 10
wmc 14
mnd 0
bc 11
fnc 11
bpm 1
cpm 1.2727
noi 1
1
/* eslint-env mocha */
2
/* eslint-disable no-unused-expressions */
3
4
var Sinon = require('sinon')
5
var Chai = require('chai')
6
var expect = Chai.expect
7
8
var VoxEngine = require('../../../../lib/Stub/VoxEngine').VoxEngine
9
10
describe('Acceptance', function () {
11
  describe('/Stub', function () {
12
    describe('/VoxEngine.js', function () {
13
      describe('.Logger', function () {
14
        var instance
15
        var allure
16
17
        beforeEach(function () {
18
          allure = global.allure
19
          global.allure = {
20
            createAttachment: Sinon.stub()
21
          }
22
          instance = new VoxEngine()
23
        })
24
25
        afterEach(function () {
26
          global.allure = allure
27
        })
28
29
        describe('#customData()', function () {
30
          it('writes data into `._state` and retrieves it', function () {
31
            expect(instance._state.customData).to.be.not.ok
32
            var value = 'wow'
33
            instance.customData(value)
34
            expect(instance._state.customData).to.eq(value)
35
            expect(instance.customData()).to.eq(value)
36
          })
37
        })
38
39
        describe('#_flush()', function () {
40
          it('doesn\'t save allure attachments if it is disabled', function () {
41
            instance = new VoxEngine({allure: {enabled: false}})
42
            instance.customData('wow')
43
            instance._flush()
44
            expect(global.allure.createAttachment.callCount).to.eq(0)
45
          })
46
47
          it('doesn\'t save allure attachments if it is missing', function () {
48
            global.allure = null
49
            instance.customData('wow')
50
            expect(instance._flush).not.to.throw()
51
          })
52
        })
53
      })
54
    })
55
  })
56
})
57