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,
);
......
......@@ -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);
});
});
});
......@@ -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