forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattachToDocument.spec.js
33 lines (31 loc) · 1.14 KB
/
attachToDocument.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, isRunningJSDOM } from '~resources/utils'
import { renderToString } from '@vue/server-test-utils'
describeWithShallowAndMount('options.attachToDocument', mountingMethod => {
it('attaches root node to document', () => {
const TestComponent = {
template: '<div class="attached"><input /></div>'
}
const wrapper = mountingMethod(TestComponent, {
attachToDocument: true
})
expect(document.querySelector('.attached')).to.not.equal(null)
expect(wrapper.options.attachedToDocument).to.equal(true)
})
})
describe('options.attachToDocument with renderToString', () => {
it('throws error that renderToString does not accept attachToDocument', () => {
// renderToString can only be run in node
if (!isRunningJSDOM) {
return
}
const TestComponent = {
template: '<div class="attached"><input /></div>'
}
const fn = () => renderToString(TestComponent, { attachToDocument: true })
const message =
'[vue-test-utils]: you cannot use attachToDocument with renderToString'
expect(fn)
.to.throw()
.with.property('message', message)
})
})