summaryrefslogtreecommitdiff
path: root/spec/frontend/design_management/components/design_note_pin_spec.js
blob: 4f7260b13635620397b86096ea5dbb2b5f8c1478 (plain)
1
2
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
import { shallowMount } from '@vue/test-utils';
import DesignNotePin from '~/design_management/components/design_note_pin.vue';

describe('Design discussions 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);
    });
  });
});