Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bundle dependencies inline and fix es build #116

Merged
merged 15 commits into from
May 13, 2020
Merged
Prev Previous commit
Next Next commit
chore: fix tests
  • Loading branch information
lmiller1990 committed May 10, 2020
commit 305fb1ab555ba3f63740a5a00b18f8585a20ee2b
4 changes: 3 additions & 1 deletion src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export function mount(
ref: MOUNT_COMPONENT_REF
})

const global = mergeGlobalProperties(config.global, options?.global)
component.components = { ...component.components, ...global.components }

// create the wrapper component
const Parent = defineComponent({
name: MOUNT_PARENT_NAME,
Expand All @@ -142,7 +145,6 @@ export function mount(

// create the app
const app = createApp(Parent)
const global = mergeGlobalProperties(config.global, options?.global)

// global mocks mixin
if (global?.mocks) {
Expand Down
18 changes: 10 additions & 8 deletions tests/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { h } from 'vue'
import { config, mount } from '../src'
import Hello from './components/Hello.vue'

Expand All @@ -13,7 +14,7 @@ describe('config', () => {
}
})

describe.skip('components', () => {
describe('components', () => {
const Component = {
components: { Hello },
template: '<div>{{ msg }} <Hello /></div>',
Expand All @@ -22,22 +23,23 @@ describe('config', () => {

it('allows setting components globally', () => {
const HelloLocal = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test if the locally registered component is overwritten properly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this in the other test (I think?)

I will check.

props: ['msg'],
template: '<div>{{ msg }}</div>'
name: 'Hello',
render() {
return h('div', 'Hello Local')
}
}
config.global.components = { Hello: HelloLocal }
const wrapper1 = mount(Component, {
props: { msg: 'Wrapper1 Overwritten' }
props: { msg: 'Wrapper1' }
})
const wrapper2 = mount(Component, {
props: { msg: 'Wrapper2 Overwritten' }
props: { msg: 'Wrapper2' }
})
expect(wrapper1.text()).toEqual('Wrapper1 Overwritten')
expect(wrapper2.text()).toEqual('Wrapper2 Overwritten')
expect(wrapper1.text()).toEqual('Wrapper1 Hello Local')
expect(wrapper2.text()).toEqual('Wrapper2 Hello Local')
})

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