-
Notifications
You must be signed in to change notification settings - Fork 667
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
Improve passing text to slots #274
Changes from 1 commit
e397ef2
76f14f6
99c0f7a
dec437c
912fbe1
3bd9da6
3c3abf8
c3750a8
66ecd96
3b99090
a07c622
192c5ac
2302443
d2a5d65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,18 @@ import Component from '~resources/components/component.vue' | |
import ComponentWithSlots from '~resources/components/component-with-slots.vue' | ||
|
||
describe('mount.slots', () => { | ||
let _window | ||
|
||
beforeEach(() => { | ||
_window = window | ||
}) | ||
|
||
afterEach(() => { | ||
/* eslint-disable */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I'm mistakenm you can just add // eslint-disable-line to the line, instead of 2 comments. Even better, you can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for pointing out. |
||
window = _window | ||
/* eslint-enable */ | ||
}) | ||
|
||
it('mounts component with default slot if passed component in slot object', () => { | ||
const wrapper = mount(ComponentWithSlots, { slots: { default: Component }}) | ||
expect(wrapper.contains(Component)).to.equal(true) | ||
|
@@ -25,6 +37,15 @@ describe('mount.slots', () => { | |
expect(wrapper.contains('span')).to.equal(true) | ||
}) | ||
|
||
it('throws error if the UserAgent is PhantomJS when passed string is in slot object', () => { | ||
/* eslint-disable */ | ||
window = { navigator: { userAgent:'PhantomJS' } } | ||
/* eslint-enable */ | ||
const message = '[vue-test-utils]: option.slots does not support PhantomJS. Please use Puppeteer' | ||
const fn = () => mount(ComponentWithSlots, { slots: { default: 'foo' }}) | ||
expect(fn).to.throw().with.property('message', message) | ||
}) | ||
|
||
it('mounts component with default slot if passed string in slot object', () => { | ||
const wrapper1 = mount(ComponentWithSlots, { slots: { default: 'foo<span>123</span>{{ foo }}' }}) | ||
expect(wrapper1.find('main').html()).to.equal('<main>foo<span>123</span>bar</main>') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOMParser isn't supported in phantomJs, so we need an alternative that will work in phantom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing.
Is there a choice not to support PhantomJS ?
IMHO, I think it is better to use Puppeteer.
It is better to introduce Puppeteer at document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of users still use phantom. We could throw an error, or a warning that phantom doesn't support markup in slots, and handle it gracefully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reply.
I will look for other ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the error message to—
option.slots does not support strings PhantomJS. Please use Puppeteer, or pass a component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry.
I did not notice your comment.
I fixed the error message.