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

uot;alert()"ꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
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-alert.spec.js ➔ ... ➔ it(ꞌShould make the dialog visibleꞌ) 0 3 1
A behaviour-for-alert.spec.js ➔ ... ➔ it(ꞌShould return a promiseꞌ) 0 3 1
A behaviour-for-alert.spec.js ➔ ... ➔ it(ꞌShould make the ok button visibleꞌ) 0 3 1
A behaviour-for-alert.spec.js ➔ ... ➔ it(ꞌShould make the cancel button visibleꞌ) 0 3 1
A behaviour-for-alert.spec.js ➔ ... ➔ before 0 4 1
1
/**
2
 * Created by Emmy on 10/8/2017.
3
 */
4
5
import Vue from 'vue'
6
import Promise from 'promise-polyfill'
7
import {assert, expect} from 'chai'
8
import * as HOOKS from '../../utilities/hooks'
9
import {nodeLength} from '../../utilities/helpers'
10
11
Vue.config.productionTip = false
12
13
describe('Calling "alert()"', function () {
14
    let dg
15
16
    before(HOOKS.sanitizeAndPrepareWindow)
17
    before(function (done) {
18
        dg = window.vm.triggerAlert()
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'), 0)
36
    })
37
})
38
39
describe('Calling "alert()", then Click "ok"', function () {
40
    before(HOOKS.sanitizeAndPrepareWindow)
41
42
    it('Should resolve the promise', function (done) {
43
        window.vm.triggerAlert().then(() => {done()}) // expected
44
        Vue.nextTick(() => window.vm.clickDialogBtn('ok'))
45
    })
46
})
47