summaryrefslogtreecommitdiff
path: root/spec/javascripts/notes/components/issue_system_note_spec.js
blob: c317ce3271676dbadb89446f7f36b6d2f2f6d518 (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
50
51
52
53
import Vue from 'vue';
import issueSystemNote from '~/notes/components/issue_system_note.vue';
import store from '~/notes/stores';

describe('issue system note', () => {
  let vm;
  let props;

  beforeEach(() => {
    props = {
      note: {
        id: 1424,
        author: {
          id: 1,
          name: 'Root',
          username: 'root',
          state: 'active',
          avatar_url: 'path',
          path: '/root',
        },
        note_html: '<p dir="auto">closed</p>',
        system_note_icon_name: 'icon_status_closed',
        created_at: '2017-08-02T10:51:58.559Z',
      },
    };

    store.dispatch('setTargetNoteHash', `note_${props.note.id}`);

    const Component = Vue.extend(issueSystemNote);
    vm = new Component({
      store,
      propsData: props,
    }).$mount();
  });

  it('should render a list item with correct id', () => {
    expect(vm.$el.getAttribute('id')).toEqual(`note_${props.note.id}`);
  });

  it('should render target class is note is target note', () => {
    expect(vm.$el.classList).toContain('target');
  });

  it('should render svg icon', () => {
    expect(vm.$el.querySelector('.timeline-icon svg')).toBeDefined();
  });

  it('should render note header component', () => {
    expect(
      vm.$el.querySelector('.system-note-message').innerHTML,
    ).toEqual(props.note.note_html);
  });
});