Skip to content

Commit ac5845e

Browse files
committed
fix: extend components correctly
1 parent 7e4350f commit ac5845e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Diff for: packages/create-instance/create-instance.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @flow
22

3-
import Vue from 'vue'
43
import { createSlotVNodes } from './add-slots'
54
import addMocks from './add-mocks'
65
import { addEventLogger } from './log-events'
@@ -71,11 +70,7 @@ export default function createInstance (
7170
_Vue.component(c, stubComponents[c])
7271
})
7372

74-
const Constructor = (typeof component === 'function' && component.prototype instanceof Vue)
75-
? component.extend(instanceOptions)
76-
: _Vue.extend(component).extend(instanceOptions)
77-
78-
// const Constructor = _Vue.extend(component).extend(instanceOptions)
73+
const Constructor = _Vue.extend(component).extend(instanceOptions)
7974

8075
Object.keys(instanceOptions.components || {}).forEach(key => {
8176
Constructor.component(key, instanceOptions.components[key])

Diff for: test/specs/mount.spec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { mount, createLocalVue } from '~vue/test-utils'
44
import Component from '~resources/components/component.vue'
55
import ComponentWithProps from '~resources/components/component-with-props.vue'
66
import ComponentWithMixin from '~resources/components/component-with-mixin.vue'
7+
import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
78
import { injectSupported, vueVersion } from '~resources/utils'
89
import {
910
describeRunIf,
1011
itDoNotRunIf
1112
} from 'conditional-specs'
13+
import Vuex from 'vuex'
1214

1315
describeRunIf(process.env.TEST_ENV !== 'node',
1416
'mount', () => {
@@ -195,6 +197,17 @@ describeRunIf(process.env.TEST_ENV !== 'node',
195197
expect(wrapper.vm.$options.listeners).to.equal(undefined)
196198
})
197199

200+
it('handles store correctly', () => {
201+
const localVue = createLocalVue()
202+
localVue.use(Vuex)
203+
const store = new Vuex.Store()
204+
const wrapper = mount(ComponentAsAClass, {
205+
store,
206+
localVue
207+
})
208+
console.log(wrapper.vm.$store.getters)
209+
})
210+
198211
it('propagates errors when they are thrown', () => {
199212
const TestComponent = {
200213
template: '<div></div>',
@@ -261,7 +274,7 @@ describeRunIf(process.env.TEST_ENV !== 'node',
261274
Vue.config.errorHandler = null
262275
})
263276

264-
it('overwrites the component options with the options other than the mounting options when the options for mount contain those', () => {
277+
it('overwrites the component options with the instance options', () => {
265278
const Component = {
266279
template: '<div>{{ foo() }}{{ bar() }}{{ baz() }}</div>',
267280
methods: {

0 commit comments

Comments
 (0)