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