Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/create-instance/create-instance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import Vue from 'vue'
import cloneDeep from 'lodash/cloneDeep'
import { addSlots } from './add-slots'
import { addScopedSlots } from './add-scoped-slots'
import addMocks from './add-mocks'
Expand Down Expand Up @@ -92,6 +93,19 @@ export default function createInstance (
addAttrs(vm, options.attrs)
addListeners(vm, options.listeners)

vm.$_vueTestUtils_mountingOptionsSlots = options.slots
vm.$_vueTestUtils_originalSlots = cloneDeep(vm.$slots)
vm.$_vueTestUtils_originalUpdate = vm._update
vm._update = function (vnode, hydrating) {
// updating slot
if (this.$_vueTestUtils_mountingOptionsSlots) {
this.$slots = cloneDeep(this.$_vueTestUtils_originalSlots)
addSlots(this, this.$_vueTestUtils_mountingOptionsSlots)
vnode = this._render()
}
this.$_vueTestUtils_originalUpdate(vnode, hydrating)
}

if (options.scopedSlots) {
if (window.navigator.userAgent.match(/PhantomJS/i)) {
throwError('the scopedSlots option does not support PhantomJS. Please use Puppeteer, or pass a component.')
Expand Down
1 change: 1 addition & 0 deletions test/specs/mounting-options/slots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
const wrapper5 = mountingMethod(ComponentWithSlots, { slots: { default: '1{{ foo }}2' }})
expect(wrapper5.find('main').html()).to.equal('<main>1bar2</main>')
wrapper5.trigger('keydown')
expect(wrapper5.find('main').html()).to.equal('<main>1BAR2</main>')
const wrapper6 = mountingMethod(ComponentWithSlots, { slots: { default: '<p>1</p><p>2</p>' }})
expect(wrapper6.find('main').html()).to.equal('<main><p>1</p><p>2</p></main>')
const wrapper7 = mountingMethod(ComponentWithSlots, { slots: { default: '1<p>2</p>3' }})
Expand Down
2 changes: 1 addition & 1 deletion test/specs/mounting-options/sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
<pre>computed.text: <em>{{ computedText }}</em></pre>
</div>
</div>
</div>
</div>
`,
data () {
return {
Expand Down