forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy.spec.js
33 lines (30 loc) · 871 Bytes
/
destroy.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
import { describeWithShallowAndMount } from '~resources/utils'
import sinon from 'sinon'
describeWithShallowAndMount('destroy', mountingMethod => {
it('triggers beforeDestroy ', () => {
const spy = sinon.stub()
mountingMethod({
render: () => {},
beforeDestroy () {
spy()
}
}).destroy()
expect(spy.calledOnce).to.equal(true)
})
it('triggers destroy ', () => {
const spy = sinon.stub()
mountingMethod({
render: () => {},
destroyed () {
spy()
}
}).destroy()
expect(spy.calledOnce).to.equal(true)
})
it('removes element from document.body', () => {
const wrapper = mountingMethod({ template: '<div />' }, { attachToDocument: true })
expect(wrapper.vm.$el.parentNode).to.equal(document.body)
wrapper.destroy()
expect(wrapper.vm.$el.parentNode).to.be.null
})
})