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');
});
});
|