2018-03-27 19:54:05 +05:30
|
|
|
import Vue from 'vue';
|
2019-02-15 15:39:39 +05:30
|
|
|
import $ from 'jquery';
|
2018-03-27 19:54:05 +05:30
|
|
|
import _ from 'underscore';
|
|
|
|
import { headersInterceptor } from 'spec/helpers/vue_resource_helper';
|
2018-03-17 18:26:18 +05:30
|
|
|
import * as actions from '~/notes/stores/actions';
|
2018-11-08 19:23:39 +05:30
|
|
|
import createStore from '~/notes/stores';
|
2018-12-05 23:21:45 +05:30
|
|
|
import mrWidgetEventHub from '~/vue_merge_request_widget/event_hub';
|
2018-03-17 18:26:18 +05:30
|
|
|
import testAction from '../../helpers/vuex_action_helper';
|
2018-03-27 19:54:05 +05:30
|
|
|
import { resetStore } from '../helpers';
|
2018-05-09 12:01:36 +05:30
|
|
|
import {
|
|
|
|
discussionMock,
|
|
|
|
notesDataMock,
|
|
|
|
userDataMock,
|
|
|
|
noteableDataMock,
|
|
|
|
individualNote,
|
|
|
|
} from '../mock_data';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('Actions Notes Store', () => {
|
2018-11-08 19:23:39 +05:30
|
|
|
let store;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
store = createStore();
|
|
|
|
});
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
afterEach(() => {
|
|
|
|
resetStore(store);
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('setNotesData', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set received notes data', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setNotesData,
|
|
|
|
notesDataMock,
|
|
|
|
{ notesData: {} },
|
|
|
|
[{ type: 'SET_NOTES_DATA', payload: notesDataMock }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setNoteableData', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set received issue data', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setNoteableData,
|
|
|
|
noteableDataMock,
|
|
|
|
{ noteableData: {} },
|
|
|
|
[{ type: 'SET_NOTEABLE_DATA', payload: noteableDataMock }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setUserData', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set received user data', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setUserData,
|
|
|
|
userDataMock,
|
|
|
|
{ userData: {} },
|
|
|
|
[{ type: 'SET_USER_DATA', payload: userDataMock }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setLastFetchedAt', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set received timestamp', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setLastFetchedAt,
|
|
|
|
'timestamp',
|
|
|
|
{ lastFetchedAt: {} },
|
|
|
|
[{ type: 'SET_LAST_FETCHED_AT', payload: 'timestamp' }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setInitialNotes', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set initial notes', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setInitialNotes,
|
|
|
|
[individualNote],
|
|
|
|
{ notes: [] },
|
2018-11-08 19:23:39 +05:30
|
|
|
[{ type: 'SET_INITIAL_DISCUSSIONS', payload: [individualNote] }],
|
2018-05-09 12:01:36 +05:30
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setTargetNoteHash', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set target note hash', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setTargetNoteHash,
|
|
|
|
'hash',
|
|
|
|
{ notes: [] },
|
|
|
|
[{ type: 'SET_TARGET_NOTE_HASH', payload: 'hash' }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toggleDiscussion', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should toggle discussion', done => {
|
|
|
|
testAction(
|
|
|
|
actions.toggleDiscussion,
|
|
|
|
{ discussionId: discussionMock.id },
|
|
|
|
{ notes: [discussionMock] },
|
|
|
|
[{ type: 'TOGGLE_DISCUSSION', payload: { discussionId: discussionMock.id } }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
describe('expandDiscussion', () => {
|
|
|
|
it('should expand discussion', done => {
|
|
|
|
testAction(
|
|
|
|
actions.expandDiscussion,
|
|
|
|
{ discussionId: discussionMock.id },
|
|
|
|
{ notes: [discussionMock] },
|
|
|
|
[{ type: 'EXPAND_DISCUSSION', payload: { discussionId: discussionMock.id } }],
|
2019-02-15 15:39:39 +05:30
|
|
|
[{ type: 'diffs/renderFileForDiscussionId', payload: discussionMock.id }],
|
2018-11-08 19:23:39 +05:30
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('collapseDiscussion', () => {
|
|
|
|
it('should commit collapse discussion', done => {
|
|
|
|
testAction(
|
|
|
|
actions.collapseDiscussion,
|
|
|
|
{ discussionId: discussionMock.id },
|
|
|
|
{ notes: [discussionMock] },
|
|
|
|
[{ type: 'COLLAPSE_DISCUSSION', payload: { discussionId: discussionMock.id } }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
describe('async methods', () => {
|
|
|
|
const interceptor = (request, next) => {
|
2018-05-09 12:01:36 +05:30
|
|
|
next(
|
|
|
|
request.respondWith(JSON.stringify({}), {
|
|
|
|
status: 200,
|
|
|
|
}),
|
|
|
|
);
|
2018-03-27 19:54:05 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('closeIssue', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('sets state as closed', done => {
|
|
|
|
store
|
|
|
|
.dispatch('closeIssue', { notesData: { closeIssuePath: '' } })
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(() => {
|
|
|
|
expect(store.state.noteableData.state).toEqual('closed');
|
|
|
|
expect(store.state.isToggleStateButtonLoading).toEqual(false);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('reopenIssue', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('sets state as reopened', done => {
|
|
|
|
store
|
|
|
|
.dispatch('reopenIssue', { notesData: { reopenIssuePath: '' } })
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(() => {
|
|
|
|
expect(store.state.noteableData.state).toEqual('reopened');
|
|
|
|
expect(store.state.isToggleStateButtonLoading).toEqual(false);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('emitStateChangedEvent', () => {
|
|
|
|
it('emits an event on the document', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
document.addEventListener('issuable_vue_app:change', event => {
|
2018-03-27 19:54:05 +05:30
|
|
|
expect(event.detail.data).toEqual({ id: '1', state: 'closed' });
|
|
|
|
expect(event.detail.isClosed).toEqual(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
store.dispatch('emitStateChangedEvent', { id: '1', state: 'closed' });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toggleStateButtonLoading', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set loading as true', done => {
|
|
|
|
testAction(
|
|
|
|
actions.toggleStateButtonLoading,
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
[{ type: 'TOGGLE_STATE_BUTTON_LOADING', payload: true }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should set loading as false', done => {
|
|
|
|
testAction(
|
|
|
|
actions.toggleStateButtonLoading,
|
|
|
|
false,
|
|
|
|
{},
|
|
|
|
[{ type: 'TOGGLE_STATE_BUTTON_LOADING', payload: false }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toggleIssueLocalState', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
it('sets issue state as closed', done => {
|
|
|
|
testAction(actions.toggleIssueLocalState, 'closed', {}, [{ type: 'CLOSE_ISSUE' }], [], done);
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it('sets issue state as reopened', done => {
|
2018-11-08 19:23:39 +05:30
|
|
|
testAction(
|
|
|
|
actions.toggleIssueLocalState,
|
|
|
|
'reopened',
|
|
|
|
{},
|
|
|
|
[{ type: 'REOPEN_ISSUE' }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('poll', () => {
|
2018-05-09 12:01:36 +05:30
|
|
|
beforeEach(done => {
|
2018-03-27 19:54:05 +05:30
|
|
|
jasmine.clock().install();
|
|
|
|
|
|
|
|
spyOn(Vue.http, 'get').and.callThrough();
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
store
|
|
|
|
.dispatch('setNotesData', notesDataMock)
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
jasmine.clock().uninstall();
|
|
|
|
});
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it('calls service with last fetched state', done => {
|
2018-03-27 19:54:05 +05:30
|
|
|
const interceptor = (request, next) => {
|
2018-05-09 12:01:36 +05:30
|
|
|
next(
|
|
|
|
request.respondWith(
|
|
|
|
JSON.stringify({
|
|
|
|
notes: [],
|
|
|
|
last_fetched_at: '123456',
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'poll-interval': '1000',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-03-27 19:54:05 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
|
|
|
Vue.http.interceptors.push(headersInterceptor);
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
store
|
|
|
|
.dispatch('poll')
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(() => new Promise(resolve => requestAnimationFrame(resolve)))
|
|
|
|
.then(() => {
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(Vue.http.get).toHaveBeenCalled();
|
2018-03-27 19:54:05 +05:30
|
|
|
expect(store.state.lastFetchedAt).toBe('123456');
|
|
|
|
|
|
|
|
jasmine.clock().tick(1500);
|
|
|
|
})
|
2018-05-09 12:01:36 +05:30
|
|
|
.then(
|
|
|
|
() =>
|
|
|
|
new Promise(resolve => {
|
|
|
|
requestAnimationFrame(resolve);
|
|
|
|
}),
|
|
|
|
)
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(() => {
|
|
|
|
expect(Vue.http.get.calls.count()).toBe(2);
|
|
|
|
expect(Vue.http.get.calls.mostRecent().args[1].headers).toEqual({
|
|
|
|
'X-Last-Fetched-At': '123456',
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(() => store.dispatch('stopPolling'))
|
|
|
|
.then(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, headersInterceptor);
|
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
describe('setNotesFetchedState', () => {
|
|
|
|
it('should set notes fetched state', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setNotesFetchedState,
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
[{ type: 'SET_NOTES_FETCHED_STATE', payload: true }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
describe('deleteNote', () => {
|
|
|
|
const interceptor = (request, next) => {
|
|
|
|
next(
|
|
|
|
request.respondWith(JSON.stringify({}), {
|
|
|
|
status: 200,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
$('body').attr('data-page', '');
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
$('body').attr('data-page', '');
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('commits DELETE_NOTE and dispatches updateMergeRequestWidget', done => {
|
|
|
|
const note = { path: `${gl.TEST_HOST}`, id: 1 };
|
|
|
|
|
|
|
|
testAction(
|
|
|
|
actions.deleteNote,
|
|
|
|
note,
|
|
|
|
store.state,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'DELETE_NOTE',
|
|
|
|
payload: note,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'updateMergeRequestWidget',
|
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
{
|
|
|
|
type: 'updateResolvableDiscussonsCounts',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('dispatches removeDiscussionsFromDiff on merge request page', done => {
|
|
|
|
const note = { path: `${gl.TEST_HOST}`, id: 1 };
|
|
|
|
|
|
|
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
|
|
|
|
|
|
|
testAction(
|
|
|
|
actions.deleteNote,
|
|
|
|
note,
|
|
|
|
store.state,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'DELETE_NOTE',
|
|
|
|
payload: note,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'updateMergeRequestWidget',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'updateResolvableDiscussonsCounts',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'diffs/removeDiscussionsFromDiff',
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('createNewNote', () => {
|
|
|
|
describe('success', () => {
|
|
|
|
const res = {
|
|
|
|
id: 1,
|
|
|
|
valid: true,
|
|
|
|
};
|
|
|
|
const interceptor = (request, next) => {
|
|
|
|
next(
|
|
|
|
request.respondWith(JSON.stringify(res), {
|
|
|
|
status: 200,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('commits ADD_NEW_NOTE and dispatches updateMergeRequestWidget', done => {
|
|
|
|
testAction(
|
|
|
|
actions.createNewNote,
|
|
|
|
{ endpoint: `${gl.TEST_HOST}`, data: {} },
|
|
|
|
store.state,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'ADD_NEW_NOTE',
|
|
|
|
payload: res,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'updateMergeRequestWidget',
|
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
{
|
|
|
|
type: 'startTaskList',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'updateResolvableDiscussonsCounts',
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('error', () => {
|
|
|
|
const res = {
|
|
|
|
errors: ['error'],
|
|
|
|
};
|
|
|
|
const interceptor = (request, next) => {
|
|
|
|
next(
|
|
|
|
request.respondWith(JSON.stringify(res), {
|
|
|
|
status: 200,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not commit ADD_NEW_NOTE or dispatch updateMergeRequestWidget', done => {
|
|
|
|
testAction(
|
|
|
|
actions.createNewNote,
|
|
|
|
{ endpoint: `${gl.TEST_HOST}`, data: {} },
|
|
|
|
store.state,
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toggleResolveNote', () => {
|
|
|
|
const res = {
|
|
|
|
resolved: true,
|
|
|
|
};
|
|
|
|
const interceptor = (request, next) => {
|
|
|
|
next(
|
|
|
|
request.respondWith(JSON.stringify(res), {
|
|
|
|
status: 200,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as note', () => {
|
|
|
|
it('commits UPDATE_NOTE and dispatches updateMergeRequestWidget', done => {
|
|
|
|
testAction(
|
|
|
|
actions.toggleResolveNote,
|
|
|
|
{ endpoint: `${gl.TEST_HOST}`, isResolved: true, discussion: false },
|
|
|
|
store.state,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'UPDATE_NOTE',
|
|
|
|
payload: res,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
2019-02-15 15:39:39 +05:30
|
|
|
{
|
|
|
|
type: 'updateResolvableDiscussonsCounts',
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
{
|
|
|
|
type: 'updateMergeRequestWidget',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as discussion', () => {
|
|
|
|
it('commits UPDATE_DISCUSSION and dispatches updateMergeRequestWidget', done => {
|
|
|
|
testAction(
|
|
|
|
actions.toggleResolveNote,
|
|
|
|
{ endpoint: `${gl.TEST_HOST}`, isResolved: true, discussion: true },
|
|
|
|
store.state,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'UPDATE_DISCUSSION',
|
|
|
|
payload: res,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
2019-02-15 15:39:39 +05:30
|
|
|
{
|
|
|
|
type: 'updateResolvableDiscussonsCounts',
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
{
|
|
|
|
type: 'updateMergeRequestWidget',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateMergeRequestWidget', () => {
|
|
|
|
it('calls mrWidget checkStatus', () => {
|
|
|
|
spyOn(mrWidgetEventHub, '$emit');
|
|
|
|
|
|
|
|
actions.updateMergeRequestWidget();
|
|
|
|
|
|
|
|
expect(mrWidgetEventHub.$emit).toHaveBeenCalledWith('mr.discussion.updated');
|
|
|
|
});
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
describe('setCommentsDisabled', () => {
|
|
|
|
it('should set comments disabled state', done => {
|
|
|
|
testAction(
|
|
|
|
actions.setCommentsDisabled,
|
|
|
|
true,
|
|
|
|
null,
|
|
|
|
[{ type: 'DISABLE_COMMENTS', payload: true }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
describe('updateResolvableDiscussonsCounts', () => {
|
|
|
|
it('commits UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', done => {
|
|
|
|
testAction(
|
|
|
|
actions.updateResolvableDiscussonsCounts,
|
|
|
|
null,
|
|
|
|
{},
|
|
|
|
[{ type: 'UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS' }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
describe('convertToDiscussion', () => {
|
|
|
|
it('commits CONVERT_TO_DISCUSSION with noteId', done => {
|
|
|
|
const noteId = 'dummy-note-id';
|
|
|
|
testAction(
|
|
|
|
actions.convertToDiscussion,
|
|
|
|
noteId,
|
|
|
|
{},
|
|
|
|
[{ type: 'CONVERT_TO_DISCUSSION', payload: noteId }],
|
|
|
|
[],
|
|
|
|
done,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|