debian-mirror-gitlab/spec/javascripts/notes/components/discussion_counter_spec.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
import Vue from 'vue';
import createStore from '~/notes/stores';
import DiscussionCounter from '~/notes/components/discussion_counter.vue';
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import { noteableDataMock, discussionMock, notesDataMock } from '../mock_data';
describe('DiscussionCounter component', () => {
let store;
let vm;
beforeEach(() => {
window.mrTabs = {};
const Component = Vue.extend(DiscussionCounter);
store = createStore();
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
vm = createComponentWithStore(Component, store);
});
afterEach(() => {
vm.$destroy();
});
describe('methods', () => {
describe('jumpToFirstUnresolvedDiscussion', () => {
it('expands unresolved discussion', () => {
spyOn(vm, 'expandDiscussion').and.stub();
const discussions = [
{
...discussionMock,
id: discussionMock.id,
notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: true }],
},
{
...discussionMock,
id: discussionMock.id + 1,
notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: false }],
},
];
const firstDiscussionId = discussionMock.id + 1;
store.replaceState({
...store.state,
discussions,
});
setFixtures(`
2018-11-18 11:00:15 +05:30
<div class="discussion" data-discussion-id="${firstDiscussionId}"></div>
2018-11-08 19:23:39 +05:30
`);
vm.jumpToFirstUnresolvedDiscussion();
expect(vm.expandDiscussion).toHaveBeenCalledWith({ discussionId: firstDiscussionId });
});
});
});
});