Commit 198a5886 authored by Paul Slaughter's avatar Paul Slaughter Committed by Chad Woolley

Clean up extra whitespace in specs

These files were updated automatically with this script:

```
result="$(awk '/[{\[]$/ { printf("%s\t", $0); next } 1' $1)"
echo "$result" > $1
yarn prettier --write $1
```
parent 5848dc8a
......@@ -13,16 +13,9 @@ describe('IDE clientside preview navigator', () => {
});
beforeEach(() => {
manager = {
bundlerURL: TEST_HOST,
iframe: {
src: '',
},
};
vm = mountComponent(Component, {
manager,
});
manager = { bundlerURL: TEST_HOST, iframe: { src: '' } };
vm = mountComponent(Component, { manager });
});
afterEach(() => {
......@@ -76,49 +69,35 @@ describe('IDE clientside preview navigator', () => {
describe('onUrlChange', () => {
it('updates the path', () => {
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
expect(vm.path).toBe('/url');
});
it('sets currentBrowsingIndex 0 if not already set', () => {
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
expect(vm.currentBrowsingIndex).toBe(0);
});
it('increases currentBrowsingIndex if path doesnt match', () => {
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
vm.onUrlChange({
url: `${TEST_HOST}/url2`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url2` });
expect(vm.currentBrowsingIndex).toBe(1);
});
it('does not increase currentBrowsingIndex if path matches', () => {
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
expect(vm.currentBrowsingIndex).toBe(0);
});
it('pushes path into navigation stack', () => {
vm.onUrlChange({
url: `${TEST_HOST}/url`,
});
vm.onUrlChange({ url: `${TEST_HOST}/url` });
expect(vm.navigationStack).toEqual(['/url']);
});
......
......@@ -21,12 +21,8 @@ describe('IDE branches actions', () => {
beforeEach(() => {
mockedContext = {
dispatch() {},
rootState: {
currentProjectId: projectData.name_with_namespace,
},
rootGetters: {
currentProject: projectData,
},
rootState: { currentProjectId: projectData.name_with_namespace },
rootGetters: { currentProject: projectData },
state: state(),
};
......@@ -51,11 +47,7 @@ describe('IDE branches actions', () => {
requestBranches,
null,
mockedContext.state,
[
{
type: types.REQUEST_BRANCHES,
},
],
[{ type: types.REQUEST_BRANCHES }],
[],
done,
);
......@@ -66,15 +58,9 @@ describe('IDE branches actions', () => {
it('should commit error', done => {
testAction(
receiveBranchesError,
{
search: TEST_SEARCH,
},
{ search: TEST_SEARCH },
mockedContext.state,
[
{
type: types.RECEIVE_BRANCHES_ERROR,
},
],
[{ type: types.RECEIVE_BRANCHES_ERROR }],
[
{
type: 'setErrorMessage',
......@@ -82,9 +68,7 @@ describe('IDE branches actions', () => {
text: 'Error loading branches.',
action: expect.any(Function),
actionText: 'Please try again',
actionPayload: {
search: TEST_SEARCH,
},
actionPayload: { search: TEST_SEARCH },
},
},
],
......@@ -99,12 +83,7 @@ describe('IDE branches actions', () => {
receiveBranchesSuccess,
branches,
mockedContext.state,
[
{
type: types.RECEIVE_BRANCHES_SUCCESS,
payload: branches,
},
],
[{ type: types.RECEIVE_BRANCHES_SUCCESS, payload: branches }],
[],
done,
);
......@@ -124,37 +103,23 @@ describe('IDE branches actions', () => {
it('calls API with params', () => {
const apiSpy = jest.spyOn(axios, 'get');
fetchBranches(mockedContext, {
search: TEST_SEARCH,
});
fetchBranches(mockedContext, { search: TEST_SEARCH });
expect(apiSpy).toHaveBeenCalledWith(expect.anything(), {
params: expect.objectContaining({
search: TEST_SEARCH,
sort: 'updated_desc',
}),
params: expect.objectContaining({ search: TEST_SEARCH, sort: 'updated_desc' }),
});
});
it('dispatches success with received data', done => {
testAction(
fetchBranches,
{
search: TEST_SEARCH,
},
{ search: TEST_SEARCH },
mockedState,
[],
[
{
type: 'requestBranches',
},
{
type: 'resetBranches',
},
{
type: 'receiveBranchesSuccess',
payload: branches,
},
{ type: 'requestBranches' },
{ type: 'resetBranches' },
{ type: 'receiveBranchesSuccess', payload: branches },
],
done,
);
......@@ -169,24 +134,13 @@ describe('IDE branches actions', () => {
it('dispatches error', done => {
testAction(
fetchBranches,
{
search: TEST_SEARCH,
},
{ search: TEST_SEARCH },
mockedState,
[],
[
{
type: 'requestBranches',
},
{
type: 'resetBranches',
},
{
type: 'receiveBranchesError',
payload: {
search: TEST_SEARCH,
},
},
{ type: 'requestBranches' },
{ type: 'resetBranches' },
{ type: 'receiveBranchesError', payload: { search: TEST_SEARCH } },
],
done,
);
......@@ -199,11 +153,7 @@ describe('IDE branches actions', () => {
resetBranches,
null,
mockedContext.state,
[
{
type: types.RESET_BRANCHES,
},
],
[{ type: types.RESET_BRANCHES }],
[],
done,
);
......
......@@ -25,11 +25,7 @@ describe('IDE file templates actions', () => {
actions.requestTemplateTypes,
null,
state,
[
{
type: types.REQUEST_TEMPLATE_TYPES,
},
],
[{ type: types.REQUEST_TEMPLATE_TYPES }],
[],
done,
);
......@@ -42,11 +38,7 @@ describe('IDE file templates actions', () => {
actions.receiveTemplateTypesError,
null,
state,
[
{
type: types.RECEIVE_TEMPLATE_TYPES_ERROR,
},
],
[{ type: types.RECEIVE_TEMPLATE_TYPES_ERROR }],
[
{
type: 'setErrorMessage',
......@@ -68,12 +60,7 @@ describe('IDE file templates actions', () => {
actions.receiveTemplateTypesSuccess,
'test',
state,
[
{
type: types.RECEIVE_TEMPLATE_TYPES_SUCCESS,
payload: 'test',
},
],
[{ type: types.RECEIVE_TEMPLATE_TYPES_SUCCESS, payload: 'test' }],
[],
done,
);
......@@ -82,23 +69,7 @@ describe('IDE file templates actions', () => {
describe('fetchTemplateTypes', () => {
describe('success', () => {
const pages = [
[
{
name: 'MIT',
},
],
[
{
name: 'Apache',
},
],
[
{
name: 'CC',
},
],
];
const pages = [[{ name: 'MIT' }], [{ name: 'Apache' }], [{ name: 'CC' }]];
beforeEach(() => {
mock.onGet(/api\/(.*)\/templates\/licenses/).reply(({ params }) => {
......@@ -106,15 +77,7 @@ describe('IDE file templates actions', () => {
const page = pages[pageNum - 1];
const hasNextPage = pageNum < pages.length;
return [
200,
page,
hasNextPage
? {
'X-NEXT-PAGE': pageNum + 1,
}
: {},
];
return [200, page, hasNextPage ? { 'X-NEXT-PAGE': pageNum + 1 } : {}];
});
});
......@@ -122,10 +85,7 @@ describe('IDE file templates actions', () => {
const dispatch = jest.fn().mockName('dispatch');
actions
.fetchTemplateTypes({
dispatch,
state,
})
.fetchTemplateTypes({ dispatch, state })
.then(done.fail)
.catch(() => {
expect(dispatch).not.toHaveBeenCalled();
......@@ -135,9 +95,7 @@ describe('IDE file templates actions', () => {
});
it('dispatches actions', done => {
state.selectedTemplateType = {
key: 'licenses',
};
state.selectedTemplateType = { key: 'licenses' };
testAction(
actions.fetchTemplateTypes,
......@@ -145,17 +103,9 @@ describe('IDE file templates actions', () => {
state,
[],
[
{
type: 'requestTemplateTypes',
},
{
type: 'receiveTemplateTypesSuccess',
payload: pages[0],
},
{
type: 'receiveTemplateTypesSuccess',
payload: pages[0].concat(pages[1]),
},
{ type: 'requestTemplateTypes' },
{ type: 'receiveTemplateTypesSuccess', payload: pages[0] },
{ type: 'receiveTemplateTypesSuccess', payload: pages[0].concat(pages[1]) },
{
type: 'receiveTemplateTypesSuccess',
payload: pages[0].concat(pages[1]).concat(pages[2]),
......@@ -172,23 +122,14 @@ describe('IDE file templates actions', () => {
});
it('dispatches actions', done => {
state.selectedTemplateType = {
key: 'licenses',
};
state.selectedTemplateType = { key: 'licenses' };
testAction(
actions.fetchTemplateTypes,
null,
state,
[],
[
{
type: 'requestTemplateTypes',
},
{
type: 'receiveTemplateTypesError',
},
],
[{ type: 'requestTemplateTypes' }, { type: 'receiveTemplateTypesError' }],
done,
);
});
......@@ -201,21 +142,12 @@ describe('IDE file templates actions', () => {
const options = {
commit,
dispatch() {},
rootGetters: {
activeFile: {
name: 'test',
prevPath: '',
},
},
rootGetters: { activeFile: { name: 'test', prevPath: '' } },
};
actions.setSelectedTemplateType(options, {
name: 'test',
});
actions.setSelectedTemplateType(options, { name: 'test' });
expect(commit).toHaveBeenCalledWith(types.SET_SELECTED_TEMPLATE_TYPE, {
name: 'test',
});
expect(commit).toHaveBeenCalledWith(types.SET_SELECTED_TEMPLATE_TYPE, { name: 'test' });
});
it('dispatches discardFileChanges if prevPath matches templates name', () => {
......@@ -224,22 +156,12 @@ describe('IDE file templates actions', () => {
commit() {},
dispatch,
rootGetters: {
activeFile: {
name: 'test',
path: 'test',
prevPath: 'test',
},
},
rootGetters: { activeFile: { name: 'test', path: 'test', prevPath: 'test' } },
};
actions.setSelectedTemplateType(options, {
name: 'test',
});
actions.setSelectedTemplateType(options, { name: 'test' });
expect(dispatch).toHaveBeenCalledWith('discardFileChanges', 'test', {
root: true,
});
expect(dispatch).toHaveBeenCalledWith('discardFileChanges', 'test', { root: true });
});
it('dispatches renameEntry if file name doesnt match', () => {
......@@ -248,28 +170,15 @@ describe('IDE file templates actions', () => {
commit() {},
dispatch,
rootGetters: {
activeFile: {
name: 'oldtest',
path: 'oldtest',
prevPath: '',
},
},
rootGetters: { activeFile: { name: 'oldtest', path: 'oldtest', prevPath: '' } },
};
actions.setSelectedTemplateType(options, {
name: 'test',
});
actions.setSelectedTemplateType(options, { name: 'test' });
expect(dispatch).toHaveBeenCalledWith(
'renameEntry',
{
path: 'oldtest',
name: 'test',
},
{
root: true,
},
{ path: 'oldtest', name: 'test' },
{ root: true },
);
});
});
......@@ -300,82 +209,53 @@ describe('IDE file templates actions', () => {
describe('fetchTemplate', () => {
describe('success', () => {
beforeEach(() => {
mock.onGet(/api\/(.*)\/templates\/licenses\/mit/).replyOnce(200, {
content: 'MIT content',
});
mock.onGet(/api\/(.*)\/templates\/licenses\/testing/).replyOnce(200, {
content: 'testing content',
});
mock
.onGet(/api\/(.*)\/templates\/licenses\/mit/)
.replyOnce(200, { content: 'MIT content' });
mock
.onGet(/api\/(.*)\/templates\/licenses\/testing/)
.replyOnce(200, { content: 'testing content' });
});
it('dispatches setFileTemplate if template already has content', done => {
const template = {
content: 'already has content',
};
const template = { content: 'already has content' };
testAction(
actions.fetchTemplate,
template,
state,
[],
[
{
type: 'setFileTemplate',
payload: template,
},
],
[{ type: 'setFileTemplate', payload: template }],
done,
);
});
it('dispatches success', done => {
const template = {
key: 'mit',
};
const template = { key: 'mit' };
state.selectedTemplateType = {
key: 'licenses',
};
state.selectedTemplateType = { key: 'licenses' };
testAction(
actions.fetchTemplate,
template,
state,
[],
[
{
type: 'setFileTemplate',
payload: {
content: 'MIT content',
},
},
],
[{ type: 'setFileTemplate', payload: { content: 'MIT content' } }],
done,
);
});
it('dispatches success and uses name key for API call', done => {
const template = {
name: 'testing',
};
const template = { name: 'testing' };
state.selectedTemplateType = {
key: 'licenses',
};
state.selectedTemplateType = { key: 'licenses' };
testAction(
actions.fetchTemplate,
template,
state,
[],
[
{
type: 'setFileTemplate',
payload: {
content: 'testing content',
},
},
],
[{ type: 'setFileTemplate', payload: { content: 'testing content' } }],
done,
);
});
......@@ -387,25 +267,16 @@ describe('IDE file templates actions', () => {
});
it('dispatches error', done => {
const template = {
name: 'testing',
};
const template = { name: 'testing' };
state.selectedTemplateType = {
key: 'licenses',
};
state.selectedTemplateType = { key: 'licenses' };
testAction(
actions.fetchTemplate,
template,
state,
[],
[
{
type: 'receiveTemplateError',
payload: template,
},
],
[{ type: 'receiveTemplateError', payload: template }],
done,
);
});
......@@ -416,54 +287,23 @@ describe('IDE file templates actions', () => {
it('dispatches changeFileContent', () => {
const dispatch = jest.fn().mockName('dispatch');
const commit = jest.fn().mockName('commit');
const rootGetters = {
activeFile: {
path: 'test',
},
};
const rootGetters = { activeFile: { path: 'test' } };
actions.setFileTemplate(
{
dispatch,
commit,
rootGetters,
},
{
content: 'content',
},
);
actions.setFileTemplate({ dispatch, commit, rootGetters }, { content: 'content' });
expect(dispatch).toHaveBeenCalledWith(
'changeFileContent',
{
path: 'test',
content: 'content',
},
{
root: true,
},
{ path: 'test', content: 'content' },
{ root: true },
);
});
it('commits SET_UPDATE_SUCCESS', () => {
const dispatch = jest.fn().mockName('dispatch');
const commit = jest.fn().mockName('commit');
const rootGetters = {
activeFile: {
path: 'test',
},
};
const rootGetters = { activeFile: { path: 'test' } };
actions.setFileTemplate(
{
dispatch,
commit,
rootGetters,
},
{
content: 'content',
},
);
actions.setFileTemplate({ dispatch, commit, rootGetters }, { content: 'content' });
expect(commit).toHaveBeenCalledWith('SET_UPDATE_SUCCESS', true);
});
......@@ -473,69 +313,34 @@ describe('IDE file templates actions', () => {
it('dispatches changeFileContent', () => {
const dispatch = jest.fn().mockName('dispatch');
const commit = jest.fn().mockName('commit');
const rootGetters = {
activeFile: {
path: 'test',
raw: 'raw content',
},
};
const rootGetters = { activeFile: { path: 'test', raw: 'raw content' } };
actions.undoFileTemplate({
dispatch,
commit,
rootGetters,
});
actions.undoFileTemplate({ dispatch, commit, rootGetters });
expect(dispatch).toHaveBeenCalledWith(
'changeFileContent',
{
path: 'test',
content: 'raw content',
},
{
root: true,
},
{ path: 'test', content: 'raw content' },
{ root: true },
);
});
it('commits SET_UPDATE_SUCCESS', () => {
const dispatch = jest.fn().mockName('dispatch');
const commit = jest.fn().mockName('commit');
const rootGetters = {
activeFile: {
path: 'test',
raw: 'raw content',
},
};
const rootGetters = { activeFile: { path: 'test', raw: 'raw content' } };
actions.undoFileTemplate({
dispatch,
commit,
rootGetters,
});
actions.undoFileTemplate({ dispatch, commit, rootGetters });
expect(commit).toHaveBeenCalledWith('SET_UPDATE_SUCCESS', false);
});
it('dispatches discardFileChanges if file has prevPath', () => {
const dispatch = jest.fn().mockName('dispatch');
const rootGetters = {
activeFile: {
path: 'test',
prevPath: 'newtest',
raw: 'raw content',
},
};
const rootGetters = { activeFile: { path: 'test', prevPath: 'newtest', raw: 'raw content' } };
actions.undoFileTemplate({
dispatch,
commit() {},
rootGetters,
});
actions.undoFileTemplate({ dispatch, commit() {}, rootGetters });
expect(dispatch).toHaveBeenCalledWith('discardFileChanges', 'test', {
root: true,
});
expect(dispatch).toHaveBeenCalledWith('discardFileChanges', 'test', { root: true });
});
});
});
......@@ -19,9 +19,7 @@ describe('IDE merge requests actions', () => {
beforeEach(() => {
mockedState = state();
mockedRootState = {
currentProjectId: 7,
};
mockedRootState = { currentProjectId: 7 };
mock = new MockAdapter(axios);
});
......@@ -35,11 +33,7 @@ describe('IDE merge requests actions', () => {
requestMergeRequests,
null,
mockedState,
[
{
type: types.REQUEST_MERGE_REQUESTS,
},
],
[{ type: types.REQUEST_MERGE_REQUESTS }],
[],
done,
);
......@@ -50,16 +44,9 @@ describe('IDE merge requests actions', () => {
it('should commit error', done => {
testAction(
receiveMergeRequestsError,
{
type: 'created',
search: '',
},
{ type: 'created', search: '' },
mockedState,
[
{
type: types.RECEIVE_MERGE_REQUESTS_ERROR,
},
],
[{ type: types.RECEIVE_MERGE_REQUESTS_ERROR }],
[
{
type: 'setErrorMessage',
......@@ -67,10 +54,7 @@ describe('IDE merge requests actions', () => {
text: 'Error loading merge requests.',
action: expect.any(Function),
actionText: 'Please try again',
actionPayload: {
type: 'created',
search: '',
},
actionPayload: { type: 'created', search: '' },
},
},
],
......@@ -85,12 +69,7 @@ describe('IDE merge requests actions', () => {
receiveMergeRequestsSuccess,
mergeRequests,
mockedState,
[
{
type: types.RECEIVE_MERGE_REQUESTS_SUCCESS,
payload: mergeRequests,
},
],
[{ type: types.RECEIVE_MERGE_REQUESTS_SUCCESS, payload: mergeRequests }],
[],
done,
);
......@@ -116,16 +95,10 @@ describe('IDE merge requests actions', () => {
state: mockedState,
rootState: mockedRootState,
},
{
type: 'created',
},
{ type: 'created' },
);
expect(apiSpy).toHaveBeenCalledWith(expect.anything(), {
params: {
scope: 'created-by-me',
state: 'opened',
search: '',
},
params: { scope: 'created-by-me', state: 'opened', search: '' },
});
});
......@@ -138,39 +111,23 @@ describe('IDE merge requests actions', () => {
state: mockedState,
rootState: mockedRootState,
},
{
type: 'created',
search: 'testing search',
},
{ type: 'created', search: 'testing search' },
);
expect(apiSpy).toHaveBeenCalledWith(expect.anything(), {
params: {
scope: 'created-by-me',
state: 'opened',
search: 'testing search',
},
params: { scope: 'created-by-me', state: 'opened', search: 'testing search' },
});
});
it('dispatches success with received data', done => {
testAction(
fetchMergeRequests,
{
type: 'created',
},
{ type: 'created' },
mockedState,
[],
[
{
type: 'requestMergeRequests',
},
{
type: 'resetMergeRequests',
},
{
type: 'receiveMergeRequestsSuccess',
payload: mergeRequests,
},
{ type: 'requestMergeRequests' },
{ type: 'resetMergeRequests' },
{ type: 'receiveMergeRequestsSuccess', payload: mergeRequests },
],
done,
);
......@@ -191,41 +148,24 @@ describe('IDE merge requests actions', () => {
state: mockedState,
rootState: mockedRootState,
},
{
type: null,
search: 'testing search',
},
{ type: null, search: 'testing search' },
);
expect(apiSpy).toHaveBeenCalledWith(
expect.stringMatching(`projects/${mockedRootState.currentProjectId}/merge_requests`),
{
params: {
state: 'opened',
search: 'testing search',
},
},
{ params: { state: 'opened', search: 'testing search' } },
);
});
it('dispatches success with received data', done => {
testAction(
fetchMergeRequests,
{
type: null,
},
{ type: null },
{ ...mockedState, ...mockedRootState },
[],
[
{
type: 'requestMergeRequests',
},
{
type: 'resetMergeRequests',
},
{
type: 'receiveMergeRequestsSuccess',
payload: mergeRequests,
},
{ type: 'requestMergeRequests' },
{ type: 'resetMergeRequests' },
{ type: 'receiveMergeRequestsSuccess', payload: mergeRequests },
],
done,
);
......@@ -240,26 +180,13 @@ describe('IDE merge requests actions', () => {
it('dispatches error', done => {
testAction(
fetchMergeRequests,
{
type: 'created',
search: '',
},
{ type: 'created', search: '' },
mockedState,
[],
[
{
type: 'requestMergeRequests',
},
{
type: 'resetMergeRequests',
},
{
type: 'receiveMergeRequestsError',
payload: {
type: 'created',
search: '',
},
},
{ type: 'requestMergeRequests' },
{ type: 'resetMergeRequests' },
{ type: 'receiveMergeRequestsError', payload: { type: 'created', search: '' } },
],
done,
);
......@@ -273,11 +200,7 @@ describe('IDE merge requests actions', () => {
resetMergeRequests,
null,
mockedState,
[
{
type: types.RESET_MERGE_REQUESTS,
},
],
[{ type: types.RESET_MERGE_REQUESTS }],
[],
done,
);
......
......@@ -3,66 +3,29 @@ import * as actions from '~/ide/stores/modules/pane/actions';
import * as types from '~/ide/stores/modules/pane/mutation_types';
describe('IDE pane module actions', () => {
const TEST_VIEW = {
name: 'test',
};
const TEST_VIEW_KEEP_ALIVE = {
name: 'test-keep-alive',
keepAlive: true,
};
const TEST_VIEW = { name: 'test' };
const TEST_VIEW_KEEP_ALIVE = { name: 'test-keep-alive', keepAlive: true };
describe('toggleOpen', () => {
it('dispatches open if closed', done => {
testAction(
actions.toggleOpen,
TEST_VIEW,
{
isOpen: false,
},
{ isOpen: false },
[],
[
{
type: 'open',
payload: TEST_VIEW,
},
],
[{ type: 'open', payload: TEST_VIEW }],
done,
);
});
it('dispatches close if opened', done => {
testAction(
actions.toggleOpen,
TEST_VIEW,
{
isOpen: true,
},
[],
[
{
type: 'close',
},
],
done,
);
testAction(actions.toggleOpen, TEST_VIEW, { isOpen: true }, [], [{ type: 'close' }], done);
});
});
describe('open', () => {
it('commits SET_OPEN', done => {
testAction(
actions.open,
null,
{},
[
{
type: types.SET_OPEN,
payload: true,
},
],
[],
done,
);
testAction(actions.open, null, {}, [{ type: types.SET_OPEN, payload: true }], [], done);
});
it('commits SET_CURRENT_VIEW if view is given', done => {
......@@ -71,14 +34,8 @@ describe('IDE pane module actions', () => {
TEST_VIEW,
{},
[
{
type: types.SET_OPEN,
payload: true,
},
{
type: types.SET_CURRENT_VIEW,
payload: TEST_VIEW.name,
},
{ type: types.SET_OPEN, payload: true },
{ type: types.SET_CURRENT_VIEW, payload: TEST_VIEW.name },
],
[],
done,
......@@ -91,18 +48,9 @@ describe('IDE pane module actions', () => {
TEST_VIEW_KEEP_ALIVE,
{},
[
{
type: types.SET_OPEN,
payload: true,
},
{
type: types.SET_CURRENT_VIEW,
payload: TEST_VIEW_KEEP_ALIVE.name,
},
{
type: types.KEEP_ALIVE_VIEW,
payload: TEST_VIEW_KEEP_ALIVE.name,
},
{ type: types.SET_OPEN, payload: true },
{ type: types.SET_CURRENT_VIEW, payload: TEST_VIEW_KEEP_ALIVE.name },
{ type: types.KEEP_ALIVE_VIEW, payload: TEST_VIEW_KEEP_ALIVE.name },
],
[],
done,
......@@ -112,19 +60,7 @@ describe('IDE pane module actions', () => {
describe('close', () => {
it('commits SET_OPEN', done => {
testAction(
actions.close,
null,
{},
[
{
type: types.SET_OPEN,
payload: false,
},
],
[],
done,
);
testAction(actions.close, null, {}, [{ type: types.SET_OPEN, payload: false }], [], done);
});
});
});
......@@ -49,11 +49,7 @@ describe('IDE pipelines actions', () => {
requestLatestPipeline,
null,
mockedState,
[
{
type: types.REQUEST_LATEST_PIPELINE,
},
],
[{ type: types.REQUEST_LATEST_PIPELINE }],
[],
done,
);
......@@ -64,20 +60,10 @@ describe('IDE pipelines actions', () => {
it('commits error', done => {
testAction(
receiveLatestPipelineError,
{
status: 404,
},
{ status: 404 },
mockedState,
[
{
type: types.RECEIVE_LASTEST_PIPELINE_ERROR,
},
],
[
{
type: 'stopPipelinePolling',
},
],
[{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }],
[{ type: 'stopPipelinePolling' }],
done,
);
});
......@@ -85,15 +71,9 @@ describe('IDE pipelines actions', () => {
it('dispatches setErrorMessage is not 404', done => {
testAction(
receiveLatestPipelineError,
{
status: 500,
},
{ status: 500 },
mockedState,
[
{
type: types.RECEIVE_LASTEST_PIPELINE_ERROR,
},
],
[{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }],
[
{
type: 'setErrorMessage',
......@@ -104,9 +84,7 @@ describe('IDE pipelines actions', () => {
actionPayload: null,
},
},
{
type: 'stopPipelinePolling',
},
{ type: 'stopPipelinePolling' },
],
done,
);
......@@ -114,11 +92,7 @@ describe('IDE pipelines actions', () => {
});
describe('receiveLatestPipelineSuccess', () => {
const rootGetters = {
lastCommit: {
id: '123',
},
};
const rootGetters = { lastCommit: { id: '123' } };
let commit;
beforeEach(() => {
......@@ -126,28 +100,12 @@ describe('IDE pipelines actions', () => {
});
it('commits pipeline', () => {
receiveLatestPipelineSuccess(
{
rootGetters,
commit,
},
{
pipelines,
},
);
receiveLatestPipelineSuccess({ rootGetters, commit }, { pipelines });
expect(commit).toHaveBeenCalledWith(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, pipelines[0]);
});
it('commits false when there are no pipelines', () => {
receiveLatestPipelineSuccess(
{
rootGetters,
commit,
},
{
pipelines: [],
},
);
receiveLatestPipelineSuccess({ rootGetters, commit }, { pipelines: [] });
expect(commit).toHaveBeenCalledWith(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, false);
});
});
......@@ -162,17 +120,9 @@ describe('IDE pipelines actions', () => {
describe('success', () => {
beforeEach(() => {
mock.onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines').reply(
200,
{
data: {
foo: 'bar',
},
},
{
'poll-interval': '10000',
},
);
mock
.onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines')
.reply(200, { data: { foo: 'bar' } }, { 'poll-interval': '10000' });
});
it('dispatches request', done => {
......@@ -181,18 +131,11 @@ describe('IDE pipelines actions', () => {
const dispatch = jest.fn().mockName('dispatch');
const rootGetters = {
lastCommit: {
id: 'abc123def456ghi789jkl',
},
currentProject: {
path_with_namespace: 'abc/def',
},
lastCommit: { id: 'abc123def456ghi789jkl' },
currentProject: { path_with_namespace: 'abc/def' },
};
fetchLatestPipeline({
dispatch,
rootGetters,
});
fetchLatestPipeline({ dispatch, rootGetters });
expect(dispatch).toHaveBeenCalledWith('requestLatestPipeline');
......@@ -231,18 +174,11 @@ describe('IDE pipelines actions', () => {
it('dispatches error', done => {
const dispatch = jest.fn().mockName('dispatch');
const rootGetters = {
lastCommit: {
id: 'abc123def456ghi789jkl',
},
currentProject: {
path_with_namespace: 'abc/def',
},
lastCommit: { id: 'abc123def456ghi789jkl' },
currentProject: { path_with_namespace: 'abc/def' },
};
fetchLatestPipeline({
dispatch,
rootGetters,
});
fetchLatestPipeline({ dispatch, rootGetters });
jest.advanceTimersByTime(1500);
......@@ -258,19 +194,7 @@ describe('IDE pipelines actions', () => {
describe('requestJobs', () => {
it('commits request', done => {
testAction(
requestJobs,
1,
mockedState,
[
{
type: types.REQUEST_JOBS,
payload: 1,
},
],
[],
done,
);
testAction(requestJobs, 1, mockedState, [{ type: types.REQUEST_JOBS, payload: 1 }], [], done);
});
});
......@@ -278,16 +202,9 @@ describe('IDE pipelines actions', () => {
it('commits error', done => {
testAction(
receiveJobsError,
{
id: 1,
},
{ id: 1 },
mockedState,
[
{
type: types.RECEIVE_JOBS_ERROR,
payload: 1,
},
],
[{ type: types.RECEIVE_JOBS_ERROR, payload: 1 }],
[
{
type: 'setErrorMessage',
......@@ -295,9 +212,7 @@ describe('IDE pipelines actions', () => {
text: 'An error occurred whilst loading the pipelines jobs.',
action: expect.anything(),
actionText: 'Please try again',
actionPayload: {
id: 1,
},
actionPayload: { id: 1 },
},
},
],
......@@ -310,20 +225,9 @@ describe('IDE pipelines actions', () => {
it('commits data', done => {
testAction(
receiveJobsSuccess,
{
id: 1,
data: jobs,
},
{ id: 1, data: jobs },
mockedState,
[
{
type: types.RECEIVE_JOBS_SUCCESS,
payload: {
id: 1,
data: jobs,
},
},
],
[{ type: types.RECEIVE_JOBS_SUCCESS, payload: { id: 1, data: jobs } }],
[],
done,
);
......@@ -331,10 +235,7 @@ describe('IDE pipelines actions', () => {
});
describe('fetchJobs', () => {
const stage = {
id: 1,
dropdownPath: `${TEST_HOST}/jobs`,
};
const stage = { id: 1, dropdownPath: `${TEST_HOST}/jobs` };
describe('success', () => {
beforeEach(() => {
......@@ -348,17 +249,8 @@ describe('IDE pipelines actions', () => {
mockedState,
[],
[
{
type: 'requestJobs',
payload: stage.id,
},
{
type: 'receiveJobsSuccess',
payload: {
id: stage.id,
data: jobs,
},
},
{ type: 'requestJobs', payload: stage.id },
{ type: 'receiveJobsSuccess', payload: { id: stage.id, data: jobs } },
],
done,
);
......@@ -377,14 +269,8 @@ describe('IDE pipelines actions', () => {
mockedState,
[],
[
{
type: 'requestJobs',
payload: stage.id,
},
{
type: 'receiveJobsError',
payload: stage,
},
{ type: 'requestJobs', payload: stage.id },
{ type: 'receiveJobsError', payload: stage },
],
done,
);
......@@ -398,12 +284,7 @@ describe('IDE pipelines actions', () => {
toggleStageCollapsed,
1,
mockedState,
[
{
type: types.TOGGLE_STAGE_COLLAPSE,
payload: 1,
},
],
[{ type: types.TOGGLE_STAGE_COLLAPSE, payload: 1 }],
[],
done,
);
......@@ -416,18 +297,8 @@ describe('IDE pipelines actions', () => {
setDetailJob,
'job',
mockedState,
[
{
type: types.SET_DETAIL_JOB,
payload: 'job',
},
],
[
{
type: 'rightPane/open',
payload: rightSidebarViews.jobsDetail,
},
],
[{ type: types.SET_DETAIL_JOB, payload: 'job' }],
[{ type: 'rightPane/open', payload: rightSidebarViews.jobsDetail }],
done,
);
});
......@@ -437,18 +308,8 @@ describe('IDE pipelines actions', () => {
setDetailJob,
null,
mockedState,
[
{
type: types.SET_DETAIL_JOB,
payload: null,
},
],
[
{
type: 'rightPane/open',
payload: rightSidebarViews.pipelines,
},
],
[{ type: types.SET_DETAIL_JOB, payload: null }],
[{ type: 'rightPane/open', payload: rightSidebarViews.pipelines }],
done,
);
});
......@@ -458,18 +319,8 @@ describe('IDE pipelines actions', () => {
setDetailJob,
'job',
mockedState,
[
{
type: types.SET_DETAIL_JOB,
payload: 'job',
},
],
[
{
type: 'rightPane/open',
payload: rightSidebarViews.jobsDetail,
},
],
[{ type: types.SET_DETAIL_JOB, payload: 'job' }],
[{ type: 'rightPane/open', payload: rightSidebarViews.jobsDetail }],
done,
);
});
......@@ -477,18 +328,7 @@ describe('IDE pipelines actions', () => {
describe('requestJobTrace', () => {
it('commits request', done => {
testAction(
requestJobTrace,
null,
mockedState,
[
{
type: types.REQUEST_JOB_TRACE,
},
],
[],
done,
);
testAction(requestJobTrace, null, mockedState, [{ type: types.REQUEST_JOB_TRACE }], [], done);
});
});
......@@ -498,11 +338,7 @@ describe('IDE pipelines actions', () => {
receiveJobTraceError,
null,
mockedState,
[
{
type: types.RECEIVE_JOB_TRACE_ERROR,
},
],
[{ type: types.RECEIVE_JOB_TRACE_ERROR }],
[
{
type: 'setErrorMessage',
......@@ -525,12 +361,7 @@ describe('IDE pipelines actions', () => {
receiveJobTraceSuccess,
'data',
mockedState,
[
{
type: types.RECEIVE_JOB_TRACE_SUCCESS,
payload: 'data',
},
],
[{ type: types.RECEIVE_JOB_TRACE_SUCCESS, payload: 'data' }],
[],
done,
);
......@@ -539,17 +370,13 @@ describe('IDE pipelines actions', () => {
describe('fetchJobTrace', () => {
beforeEach(() => {
mockedState.detailJob = {
path: `${TEST_HOST}/project/builds`,
};
mockedState.detailJob = { path: `${TEST_HOST}/project/builds` };
});
describe('success', () => {
beforeEach(() => {
jest.spyOn(axios, 'get');
mock.onGet(`${TEST_HOST}/project/builds/trace`).replyOnce(200, {
html: 'html',
});
mock.onGet(`${TEST_HOST}/project/builds/trace`).replyOnce(200, { html: 'html' });
});
it('dispatches request', done => {
......@@ -559,15 +386,8 @@ describe('IDE pipelines actions', () => {
mockedState,
[],
[
{
type: 'requestJobTrace',
},
{
type: 'receiveJobTraceSuccess',
payload: {
html: 'html',
},
},
{ type: 'requestJobTrace' },
{ type: 'receiveJobTraceSuccess', payload: { html: 'html' } },
],
done,
);
......@@ -580,9 +400,7 @@ describe('IDE pipelines actions', () => {
dispatch() {},
});
expect(axios.get).toHaveBeenCalledWith(`${TEST_HOST}/project/builds/trace`, {
params: {
format: 'json',
},
params: { format: 'json' },
});
});
});
......@@ -598,14 +416,7 @@ describe('IDE pipelines actions', () => {
null,
mockedState,
[],
[
{
type: 'requestJobTrace',
},
{
type: 'receiveJobTraceError',
},
],
[{ type: 'requestJobTrace' }, { type: 'receiveJobTraceError' }],
done,
);
});
......@@ -619,14 +430,8 @@ describe('IDE pipelines actions', () => {
null,
mockedState,
[
{
type: types.RECEIVE_LASTEST_PIPELINE_SUCCESS,
payload: null,
},
{
type: types.SET_DETAIL_JOB,
payload: null,
},
{ type: types.RECEIVE_LASTEST_PIPELINE_SUCCESS, payload: null },
{ type: types.SET_DETAIL_JOB, payload: null },
],
[],
done,
......
......@@ -51,12 +51,8 @@ describe('IDE pipelines mutations', () => {
expect(mockedState.latestPipeline).toEqual({
id: '51',
path: 'test',
commit: {
id: '123',
},
details: {
status: expect.any(Object),
},
commit: { id: '123' },
details: { status: expect.any(Object) },
yamlError: undefined,
});
});
......@@ -129,24 +125,16 @@ describe('IDE pipelines mutations', () => {
beforeEach(() => {
mockedState.stages = stages.map((stage, i) => ({ ...stage, id: i }));
data = {
latest_statuses: [...jobs],
};
data = { latest_statuses: [...jobs] };
});
it('updates loading', () => {
mutations[types.RECEIVE_JOBS_SUCCESS](mockedState, {
id: mockedState.stages[0].id,
data,
});
mutations[types.RECEIVE_JOBS_SUCCESS](mockedState, { id: mockedState.stages[0].id, data });
expect(mockedState.stages[0].isLoading).toBe(false);
});
it('sets jobs on stage', () => {
mutations[types.RECEIVE_JOBS_SUCCESS](mockedState, {
id: mockedState.stages[0].id,
data,
});
mutations[types.RECEIVE_JOBS_SUCCESS](mockedState, { id: mockedState.stages[0].id, data });
expect(mockedState.stages[0].jobs.length).toBe(jobs.length);
expect(mockedState.stages[0].jobs).toEqual(
jobs.map(job => ({
......@@ -217,9 +205,7 @@ describe('IDE pipelines mutations', () => {
});
it('sets output on detail job', () => {
mutations[types.RECEIVE_JOB_TRACE_SUCCESS](mockedState, {
html: 'html',
});
mutations[types.RECEIVE_JOB_TRACE_SUCCESS](mockedState, { html: 'html' });
expect(mockedState.detailJob.output).toBe('html');
expect(mockedState.detailJob.isLoading).toBe(false);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment