index.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import Cell from '..';
  2. import { mount } from '../../../test/utils';
  3. test('click event', () => {
  4. const click = jest.fn();
  5. const wrapper = mount(Cell, {
  6. context: {
  7. on: {
  8. click
  9. }
  10. }
  11. });
  12. wrapper.trigger('click');
  13. expect(click).toHaveBeenCalled();
  14. });
  15. test('arrow direction', () => {
  16. const wrapper = mount(Cell, {
  17. propsData: {
  18. isLink: true,
  19. arrowDirection: 'down'
  20. }
  21. });
  22. expect(wrapper).toMatchSnapshot();
  23. });
  24. test('render slot', () => {
  25. const wrapper = mount({
  26. template: `
  27. <cell>
  28. <template v-slot:title>Custom Title</template>
  29. <template v-slot:label>Custom Label</template>
  30. <template v-slot:extra>Custom Extra</template>
  31. </cell>
  32. `,
  33. components: {
  34. Cell
  35. }
  36. });
  37. expect(wrapper).toMatchSnapshot();
  38. });
  39. test('title-style prop', () => {
  40. const wrapper = mount(Cell, {
  41. propsData: {
  42. title: 'title',
  43. titleStyle: {
  44. color: 'red'
  45. }
  46. }
  47. });
  48. expect(wrapper).toMatchSnapshot();
  49. });