forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue-wrapper.spec.js
40 lines (33 loc) · 1.21 KB
/
vue-wrapper.spec.js
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
38
39
40
import { describeWithShallowAndMount } from '~resources/utils'
describeWithShallowAndMount('VueWrapper', mountingMethod => {
;['vnode', 'element', 'vm', 'options'].forEach(property => {
it(`has the ${property} property which is read-only`, () => {
const wrapper = mountingMethod({ template: '<div><p></p></div>' })
expect(wrapper.constructor.name).to.equal('VueWrapper')
const message = `[vue-test-utils]: wrapper.${property} is read-only`
expect(() => {
wrapper[property] = 'foo'
})
.to.throw()
.with.property('message', message)
})
})
describe('debug function', () => {
const sandbox = sinon.createSandbox()
beforeEach(() => {
sandbox.spy(console, 'log')
})
it('writes to the console formated html content of the vue-wrapper', () => {
const basicComponent = { template: '<div><p>Debug me please</p></div>' }
const wrapper = mountingMethod(basicComponent)
wrapper.debug()
expect(console.log).to.have.been.calledWith('Wrapper:')
expect(console.log).to.have.been.calledWith(
'<div>\n' + ' <p>Debug me please</p>\n' + '</div>\n'
)
})
afterEach(() => {
sandbox.restore()
})
})
})