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: {
src: '',
},
};
vm = mountComponent(Component, { vm = mountComponent(Component, { manager });
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,
); );
......
...@@ -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,
);
}); });
}); });
}); });
...@@ -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