Skip to content

Commit 305fb1a

Browse files
committed
chore: fix tests
1 parent 2e3044d commit 305fb1a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/mount.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ export function mount(
124124
ref: MOUNT_COMPONENT_REF
125125
})
126126

127+
const global = mergeGlobalProperties(config.global, options?.global)
128+
component.components = { ...component.components, ...global.components }
129+
127130
// create the wrapper component
128131
const Parent = defineComponent({
129132
name: MOUNT_PARENT_NAME,
@@ -142,7 +145,6 @@ export function mount(
142145

143146
// create the app
144147
const app = createApp(Parent)
145-
const global = mergeGlobalProperties(config.global, options?.global)
146148

147149
// global mocks mixin
148150
if (global?.mocks) {

tests/config.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { h } from 'vue'
12
import { config, mount } from '../src'
23
import Hello from './components/Hello.vue'
34

@@ -13,7 +14,7 @@ describe('config', () => {
1314
}
1415
})
1516

16-
describe.skip('components', () => {
17+
describe('components', () => {
1718
const Component = {
1819
components: { Hello },
1920
template: '<div>{{ msg }} <Hello /></div>',
@@ -22,22 +23,23 @@ describe('config', () => {
2223

2324
it('allows setting components globally', () => {
2425
const HelloLocal = {
25-
props: ['msg'],
26-
template: '<div>{{ msg }}</div>'
26+
name: 'Hello',
27+
render() {
28+
return h('div', 'Hello Local')
29+
}
2730
}
2831
config.global.components = { Hello: HelloLocal }
2932
const wrapper1 = mount(Component, {
30-
props: { msg: 'Wrapper1 Overwritten' }
33+
props: { msg: 'Wrapper1' }
3134
})
3235
const wrapper2 = mount(Component, {
33-
props: { msg: 'Wrapper2 Overwritten' }
36+
props: { msg: 'Wrapper2' }
3437
})
35-
expect(wrapper1.text()).toEqual('Wrapper1 Overwritten')
36-
expect(wrapper2.text()).toEqual('Wrapper2 Overwritten')
38+
expect(wrapper1.text()).toEqual('Wrapper1 Hello Local')
39+
expect(wrapper2.text()).toEqual('Wrapper2 Hello Local')
3740
})
3841

3942
it('allows overwriting globally set component config on a per mount instance', () => {
40-
console.log('TODO: Fix this')
4143
config.global.components = { Hello }
4244
const HelloLocal = { template: '<div>Hello Overwritten</div>' }
4345
const wrapper1 = mount(Component, { props: { msg: 'Wrapper1' } })

0 commit comments

Comments
 (0)