design_note_pin_spec.js 1.3 KB
Newer Older
1
import { shallowMount } from '@vue/test-utils';
2
import DesignNotePin from '~/design_management_legacy/components/design_note_pin.vue';
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

describe('Design note pin component', () => {
  let wrapper;

  function createComponent(propsData = {}) {
    wrapper = shallowMount(DesignNotePin, {
      propsData: {
        position: {
          left: '10px',
          top: '10px',
        },
        ...propsData,
      },
    });
  }

  afterEach(() => {
    wrapper.destroy();
  });

  it('should match the snapshot of note without index', () => {
    createComponent();
    expect(wrapper.element).toMatchSnapshot();
  });

  it('should match the snapshot of note with index', () => {
    createComponent({ label: 1 });
    expect(wrapper.element).toMatchSnapshot();
  });

  it('should match the snapshot of note when repositioning', () => {
    createComponent({ repositioning: true });
    expect(wrapper.element).toMatchSnapshot();
  });

  describe('pinStyle', () => {
    it('sets cursor to `move` when repositioning = true', () => {
      createComponent({ repositioning: true });
      expect(wrapper.vm.pinStyle.cursor).toBe('move');
    });

    it('does not set cursor when repositioning = false', () => {
      createComponent();
      expect(wrapper.vm.pinStyle.cursor).toBe(undefined);
    });
  });
});