mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] add test case for field icon props (#2876)
This commit is contained in:
parent
60b5e188c8
commit
4ad382b33a
@ -26,6 +26,17 @@ exports[`render label slot 1`] = `
|
|||||||
</div>
|
</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`] = `
|
exports[`render textarea 1`] = `
|
||||||
<div class="van-cell van-field">
|
<div class="van-cell van-field">
|
||||||
<div class="van-cell__value van-cell__value--alone">
|
<div class="van-cell__value van-cell__value--alone">
|
||||||
|
@ -178,3 +178,12 @@ test('render label slot', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('render right icon with icon prop for old version', () => {
|
||||||
|
const wrapper = mount(Field, {
|
||||||
|
propsData: {
|
||||||
|
icon: 'success'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
@ -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>
|
||||||
|
`;
|
@ -29,3 +29,23 @@ test('MiniBtn click event', () => {
|
|||||||
wrapper.trigger('click');
|
wrapper.trigger('click');
|
||||||
expect(click.mock.calls.length).toEqual(1);
|
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();
|
||||||
|
});
|
||||||
|
16
packages/icon/test/__snapshots__/index.spec.js.snap
Normal file
16
packages/icon/test/__snapshots__/index.spec.js.snap
Normal 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>
|
||||||
|
`;
|
29
packages/icon/test/index.spec.js
Normal file
29
packages/icon/test/index.spec.js
Normal 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();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user