Welcome to mirror list, hosted at ThFree Co, Russian Federation.

diff_file_drafts_spec.js « components « batch_comments « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6e0b61db9fa2d239f072c3acce6a8e4df37390f5 (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
54
55
56
57
58
59
60
61
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import DiffFileDrafts from '~/batch_comments/components/diff_file_drafts.vue';
import DraftNote from '~/batch_comments/components/draft_note.vue';

const localVue = createLocalVue();

localVue.use(Vuex);

describe('Batch comments diff file drafts component', () => {
  let vm;

  function factory() {
    const store = new Vuex.Store({
      modules: {
        batchComments: {
          namespaced: true,
          getters: {
            draftsForFile: () => () => [{ id: 1 }, { id: 2 }],
          },
        },
      },
    });

    vm = shallowMount(localVue.extend(DiffFileDrafts), {
      store,
      localVue,
      propsData: { fileHash: 'filehash' },
    });
  }

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

  it('renders list of draft notes', () => {
    factory();

    expect(vm.findAll(DraftNote).length).toEqual(2);
  });

  it('renders index of draft note', () => {
    factory();

    expect(vm.findAll('.js-diff-notes-index').length).toEqual(2);

    expect(
      vm
        .findAll('.js-diff-notes-index')
        .at(0)
        .text(),
    ).toEqual('1');

    expect(
      vm
        .findAll('.js-diff-notes-index')
        .at(1)
        .text(),
    ).toEqual('2');
  });
});