index.spec.js 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import SubmitBar from '..';
  2. import { mount } from '../../../test/utils';
  3. test('submit', () => {
  4. const submit = jest.fn();
  5. const wrapper = mount(SubmitBar, {
  6. context: {
  7. props: {
  8. price: 1
  9. },
  10. on: { submit }
  11. }
  12. });
  13. const button = wrapper.find('.van-button');
  14. button.trigger('click');
  15. expect(submit).toHaveBeenCalled();
  16. });
  17. test('disable submit', () => {
  18. const submit = jest.fn();
  19. const wrapper = mount(SubmitBar, {
  20. context: {
  21. props: {
  22. price: 1,
  23. disabled: true
  24. },
  25. on: { submit }
  26. }
  27. });
  28. expect(wrapper).toMatchSnapshot();
  29. // disabled
  30. const button = wrapper.find('.van-button');
  31. button.trigger('click');
  32. expect(submit).toHaveBeenCalledTimes(0);
  33. });
  34. test('decimal length', () => {
  35. const wrapper = mount(SubmitBar, {
  36. context: {
  37. props: {
  38. price: 111,
  39. decimalLength: 1
  40. }
  41. }
  42. });
  43. expect(wrapper).toMatchSnapshot();
  44. });