summaryrefslogtreecommitdiff
path: root/spec/javascripts/notes/components/note_edited_text_spec.js
blob: e0b991c32ec3a4581ecfcea6504d95331ec4b2ce (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
import Vue from 'vue';
import noteEditedText from '~/notes/components/note_edited_text.vue';

describe('note_edited_text', () => {
  let vm;
  let props;

  beforeEach(() => {
    const Component = Vue.extend(noteEditedText);
    props = {
      actionText: 'Edited',
      className: 'foo-bar',
      editedAt: '2017-08-04T09:52:31.062Z',
      editedBy: {
        avatar_url: 'path',
        id: 1,
        name: 'Root',
        path: '/root',
        state: 'active',
        username: 'root',
      },
    };

    vm = new Component({
      propsData: props,
    }).$mount();
  });

  afterEach(() => {
    vm.$destroy();
  });

  it('should render block with provided className', () => {
    expect(vm.$el.className).toEqual(props.className);
  });

  it('should render provided actionText', () => {
    expect(vm.$el.textContent).toContain(props.actionText);
  });

  it('should render provided user information', () => {
    const authorLink = vm.$el.querySelector('.js-vue-author');

    expect(authorLink.getAttribute('href')).toEqual(props.editedBy.path);
    expect(authorLink.textContent.trim()).toEqual(props.editedBy.name);
  });
});