index.spec.js 741 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import Switch from '..';
  2. import { mount } from '../../../test/utils';
  3. test('emit event', () => {
  4. const input = jest.fn();
  5. const change = jest.fn();
  6. const wrapper = mount(Switch, {
  7. context: {
  8. on: {
  9. input,
  10. change
  11. }
  12. }
  13. });
  14. wrapper.trigger('click');
  15. expect(input).toHaveBeenCalledWith(true);
  16. expect(change).toHaveBeenCalledWith(true);
  17. });
  18. test('disabled', () => {
  19. const input = jest.fn();
  20. const change = jest.fn();
  21. const wrapper = mount(Switch, {
  22. context: {
  23. on: {
  24. input,
  25. change
  26. }
  27. },
  28. propsData: {
  29. disabled: true
  30. }
  31. });
  32. wrapper.trigger('click');
  33. expect(input).toHaveBeenCalledTimes(0);
  34. expect(change).toHaveBeenCalledTimes(0);
  35. });