mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
52 lines
977 B
JavaScript
52 lines
977 B
JavaScript
import Button from '../../goods-action-button';
|
|
import Icon from '../../goods-action-icon';
|
|
import { mount } from '../../../test/utils';
|
|
|
|
test('Button click event', () => {
|
|
const click = jest.fn();
|
|
const wrapper = mount(Button, {
|
|
context: {
|
|
on: {
|
|
click
|
|
}
|
|
}
|
|
});
|
|
|
|
wrapper.trigger('click');
|
|
expect(click).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
test('Icon click event', () => {
|
|
const click = jest.fn();
|
|
const wrapper = mount(Icon, {
|
|
context: {
|
|
on: {
|
|
click
|
|
}
|
|
}
|
|
});
|
|
|
|
wrapper.trigger('click');
|
|
expect(click).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
test('Button render default slot', () => {
|
|
const wrapper = mount({
|
|
render(h) {
|
|
return h(Button, null, ['Default Content']);
|
|
}
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
test('Icon render default slot', () => {
|
|
const wrapper = mount({
|
|
render(h) {
|
|
return h(Icon, null, ['Default Content']);
|
|
}
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|