[improvement] add test case for field icon props (#2876)

This commit is contained in:
neverland 2019-03-01 14:18:29 +08:00 committed by GitHub
parent 60b5e188c8
commit 4ad382b33a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 93 additions and 0 deletions

View File

@ -26,6 +26,17 @@ exports[`render label slot 1`] = `
</div>
`;
exports[`render right icon with icon prop for old version 1`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone">
<div class="van-field__body"><input type="text" class="van-field__control">
<div class="van-field__right-icon"><i class="van-icon van-icon-success">
<!----></i></div>
</div>
</div>
</div>
`;
exports[`render textarea 1`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone">

View File

@ -178,3 +178,12 @@ test('render label slot', () => {
expect(wrapper).toMatchSnapshot();
});
test('render right icon with icon prop for old version', () => {
const wrapper = mount(Field, {
propsData: {
icon: 'success'
}
});
expect(wrapper).toMatchSnapshot();
});

View File

@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`BigBtn render default slot 1`] = `<button class="van-button van-button--warning van-button--large van-button--square van-goods-action-big-btn"><span class="van-button__text">Default Content</span></button>`;
exports[`Mini render default slot 1`] = `
<div class="van-goods-action-mini-btn van-hairline"><i class="van-icon van-icon-undefined van-goods-action-mini-btn__icon">
<!----></i>Default Content</div>
`;

View File

@ -29,3 +29,23 @@ test('MiniBtn click event', () => {
wrapper.trigger('click');
expect(click.mock.calls.length).toEqual(1);
});
test('BigBtn render default slot', () => {
const wrapper = mount({
render(h) {
return h(BigBtn, null, ['Default Content']);
}
});
expect(wrapper).toMatchSnapshot();
});
test('Mini render default slot', () => {
const wrapper = mount({
render(h) {
return h(MiniBtn, null, ['Default Content']);
}
});
expect(wrapper).toMatchSnapshot();
});

View File

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`render icon default slot 1`] = `
<i class="van-icon van-icon-success">Default slot
<!----></i>
`;
exports[`render icon with builtin icon name 1`] = `
<i class="van-icon van-icon-success">
<!----></i>
`;
exports[`render icon with url name 1`] = `
<i class="van-icon van-icon--image"><img src="https://img.yzcdn.com/icon.jpg">
<!----></i>
`;

View File

@ -0,0 +1,29 @@
import Icon from '..';
import { mount } from '../../../test/utils';
test('render icon with builtin icon name', () => {
const wrapper = mount(Icon, {
propsData: {
name: 'success'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render icon with url name', () => {
const wrapper = mount(Icon, {
propsData: {
name: 'https://img.yzcdn.com/icon.jpg'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render icon default slot', () => {
const wrapper = mount({
render(h) {
return h(Icon, { props: { name: 'success' } }, ['Default slot']);
}
});
expect(wrapper).toMatchSnapshot();
});