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] Fix named functional text slots #734

Closed
Closed
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
35 changes: 33 additions & 2 deletions test/specs/mounting-options/slots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describeWithMountingMethods('options.slots', mountingMethod => {
}
})

it('mounts component with text slot', () => {
it('mounts component with named and default text slot', () => {
const wrapper = mountingMethod(ComponentWithSlots, {
slots: {
default: 'hello,',
Expand All @@ -235,7 +235,20 @@ describeWithMountingMethods('options.slots', mountingMethod => {
}
})

it('mounts functional component with text slot', () => {
it('mounts component with named text slot', () => {
const wrapper = mountingMethod(ComponentWithSlots, {
slots: {
header: 'world'
}
})
if (mountingMethod.name === 'renderToString') {
expect(wrapper).contains('world')
} else {
expect(wrapper.text()).to.contain('world')
}
})

it('mounts functional component with named and default text slot', () => {
const TestComponent = {
name: 'component-with-slots',
functional: true,
Expand All @@ -254,6 +267,24 @@ describeWithMountingMethods('options.slots', mountingMethod => {
}
})

it('mounts functional component with named text slot', () => {
const TestComponent = {
name: 'component-with-slots',
functional: true,
render: (h, ctx) => h('div', ctx.data, [ctx.slots().header])
}
const wrapper = mountingMethod(TestComponent, {
slots: {
header: 'world'
}
})
if (mountingMethod.name === 'renderToString') {
expect(wrapper).contains('world')
} else {
expect(wrapper.text()).to.contain('world')
}
})

it('mounts component with named slot if passed component in slot object', () => {
const wrapper = mountingMethod(ComponentWithSlots, {
slots: {
Expand Down