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

WIP: feat/fix: stub out transitions by default #1411

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/create-instance/create-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function createInstance(
const stubComponentsObject = createStubsFromStubsObject(
componentOptions.components,
// $FlowIgnore
options.stubs,
{ ...options.stubs, transition: true },
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt we add this to the default stubs in options? Wont it be a bit cleaner?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this might not be the best place to add this - which line/file do you think we should add this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Didnt we have a default global stubs object?

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 do - updated the PR, good suggestion

_Vue
)

Expand Down
20 changes: 20 additions & 0 deletions test/resources/components/component-with-transitions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<transition>
<span v-if="!expanded" data-testid="expanded">
Content
</span>
</transition>
</div>
</template>

<script>
export default {
name: 'component-with-transitions',
data() {
return {
expanded: false
}
}
}
</script>
9 changes: 9 additions & 0 deletions test/specs/mounting-options/stubs.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ComponentWithChild from '~resources/components/component-with-child.vue'
import ComponentWithTransitions from '~resources/components/component-with-transitions.vue'
import ComponentWithNestedChildren from '~resources/components/component-with-nested-children.vue'
import Component from '~resources/components/component.vue'
import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
Expand Down Expand Up @@ -53,6 +54,14 @@ describeWithShallowAndMount('options.stub', mountingMethod => {
expect(wrapper.findAll(Component).length).to.equal(1)
})

it('stubs out transitions by default', async () => {
const wrapper = mountingMethod(ComponentWithTransitions)
expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(true)
wrapper.setData({ expanded: true })
await wrapper.vm.$nextTick()
expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(false)
})

it('replaces component with a component', () => {
const mounted = sandbox.stub()
const Stub = {
Expand Down