[improvement] GoodsAction: subComponents functional (#2730)

This commit is contained in:
neverland
2019-02-13 17:56:19 +08:00
committed by GitHub
parent 4aad9add9c
commit d7c337710c
6 changed files with 67 additions and 36 deletions
+21 -7
View File
@@ -1,17 +1,31 @@
import BigBtn from '../../goods-action-big-btn';
import SmallBtn from '../../goods-action-mini-btn';
import MiniBtn from '../../goods-action-mini-btn';
import { mount } from '../../../test/utils';
test('big btn click event', () => {
const wrapper = mount(BigBtn);
test('BigBtn click event', () => {
const click = jest.fn();
const wrapper = mount(BigBtn, {
context: {
on: {
click
}
}
});
wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeTruthy();
expect(click.mock.calls.length).toEqual(1);
});
test('small btn click event', () => {
const wrapper = mount(SmallBtn);
test('MiniBtn click event', () => {
const click = jest.fn();
const wrapper = mount(MiniBtn, {
context: {
on: {
click
}
}
});
wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeTruthy();
expect(click.mock.calls.length).toEqual(1);
});