Completed
Push — master ( e9cdde...e60414 )
by Ajeh
33s
created

uot;confirm()"ꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 25
rs 8.8571
nop 0

5 Functions

Rating   Name   Duplication   Size   Complexity  
A behaviour-for-confirm.spec.js ➔ ... ➔ it(ꞌShould make the cancel button visibleꞌ) 0 3 1
A behaviour-for-confirm.spec.js ➔ ... ➔ before 0 4 1
A behaviour-for-confirm.spec.js ➔ ... ➔ it(ꞌShould return a promiseꞌ) 0 3 1
A behaviour-for-confirm.spec.js ➔ ... ➔ it(ꞌShould make the dialog visibleꞌ) 0 3 1
A behaviour-for-confirm.spec.js ➔ ... ➔ it(ꞌShould make the ok button visibleꞌ) 0 3 1
1
/**
2
 * Created by Emmy on 10/8/2017.
3
 */
4
5
import * as HOOKS from '../../utilities/hooks'
6
import {getElem, nodeLength} from '../../utilities/helpers'
0 ignored issues
show
Unused Code introduced by
The variable getElem seems to be never used. Consider removing it.
Loading history...
7
import { assert, expect } from 'chai'
8
import Vue from 'vue'
9
import Promise from 'promise-polyfill'
10
11
Vue.config.productionTip = false
12
13
describe('Calling "confirm()"', function () {
14
    let dg
15
16
    before(HOOKS.sanitizeAndPrepareWindow)
17
    before(function (done) {
18
        dg = window.vm.triggerConfirm()
19
        Vue.nextTick(done) // be sure done has updated before proceeding
20
    })
21
22
    it('Should return a promise', function () {
23
        expect(dg).to.be.instanceOf(Promise)
24
    })
25
26
    it('Should make the dialog visible', function () {
27
        assert.strictEqual(nodeLength('.dg-container'), 1)
28
    })
29
30
    it('Should make the ok button visible', function () {
31
        assert.strictEqual(nodeLength('.dg-btn--ok'), 1)
32
    })
33
34
    it('Should make the cancel button visible', function () {
35
        assert.strictEqual(nodeLength('.dg-btn--cancel'), 1)
36
    })
37
})
38
39
describe('Clicking \'ok\' on #confirm()', function () {
40
    beforeEach(HOOKS.sanitizeAndPrepareWindow)
41
42
    it('Should resolve the promise', function (done) {
43
        window.vm.triggerConfirm().then(() => {done()}) // expected
44
        Vue.nextTick(() => window.vm.clickDialogBtn('ok'))
45
    })
46
})
47
48
describe('Clicking \'cancel\' on #confirm()', function () {
49
    beforeEach(HOOKS.sanitizeAndPrepareWindow)
50
51
    it('Should reject the promise', function (done) {
52
        window.vm.triggerConfirm()
53
            .then(() => {done(new Error('Cancel button should Reject promise'))})
54
            .catch(() => {done()}) // expected
55
        Vue.nextTick(() => window.vm.clickDialogBtn('cancel'))
56
    })
57
})