All files / tests/unit utils.js

88.24% Statements 15/17
75% Branches 3/4
90.91% Functions 10/11
86.67% Lines 13/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37    3x 3x       26x 26x 26x     26x               26x 26x           26x 26x 26x 26x         3x  
'use strict'
 
const Vue = require('vue');
const Html2jade = require('html2jade');
 
/** convert html to pug as a Promise */
function html2pug (html) {
    return new Promise((resolve, reject) => {
        Html2jade.convertHtml(html, { bodyless: true }, (err, jade) => {
            Iif (err) {
                reject(err)
            } else {
                resolve(jade)
            }
        })
    })
}
 
/** call vm.nextTick() as a Promise */
function nextTick () {
    return new Promise((resolve) => {
        Vue.nextTick(() => resolve())
    })
}
 
/** call vm.nextTick() and check the snapshot as a Promise */
function expectToMatchSnapshot (vm, element) {
    return new Promise((resolve, reject) => {
        nextTick(vm).then(() => html2pug((element || vm.$el).innerHTML)).then((jade) => {
            expect(jade).toMatchSnapshot()
            resolve()
        }).catch((err) => (reject(err)))
    })
}
 
exports.expectToMatchSnapshot = expectToMatchSnapshot