blob: 8805f6bf20439414e67dc8d5654d2c5b7eb72709 (
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 Vue from 'vue';
import Vuex from 'vuex';
import DiffFileDrafts from '~/batch_comments/components/diff_file_drafts.vue';
import DraftNote from '~/batch_comments/components/draft_note.vue';
Vue.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(DiffFileDrafts, {
store,
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');
});
});
|