Commit 280a79c0 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 31 files - 60 of 73

Part of our prettier migration; changing the arrow-parens style.
parent e94556e9
...@@ -1887,39 +1887,6 @@ spec/frontend/helpers/vuex_action_helper_spec.js ...@@ -1887,39 +1887,6 @@ spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/wait_for_promises.js spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_using_real_timer.js spec/frontend/helpers/wait_using_real_timer.js
## jovial-mirzakhani
spec/frontend/ide/components/repo_commit_section_spec.js
spec/frontend/ide/components/repo_editor_spec.js
spec/frontend/ide/components/repo_tabs_spec.js
spec/frontend/ide/components/resizable_panel_spec.js
spec/frontend/ide/components/shared/tokened_input_spec.js
spec/frontend/ide/components/terminal/session_spec.js
spec/frontend/ide/components/terminal/terminal_controls_spec.js
spec/frontend/ide/components/terminal/terminal_spec.js
spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js
spec/frontend/ide/file_helpers.js
spec/frontend/ide/helpers.js
spec/frontend/ide/ide_router_extension_spec.js
spec/frontend/ide/ide_router_spec.js
spec/frontend/ide/lib/common/model_spec.js
spec/frontend/ide/lib/create_diff_spec.js
spec/frontend/ide/lib/create_file_diff_spec.js
spec/frontend/ide/lib/diff/controller_spec.js
spec/frontend/ide/lib/editor_spec.js
spec/frontend/ide/lib/editorconfig/parser_spec.js
spec/frontend/ide/lib/errors_spec.js
spec/frontend/ide/lib/files_spec.js
spec/frontend/ide/lib/mirror_spec.js
spec/frontend/ide/services/index_spec.js
spec/frontend/ide/stores/actions/file_spec.js
spec/frontend/ide/stores/actions/merge_request_spec.js
spec/frontend/ide/stores/actions/project_spec.js
spec/frontend/ide/stores/actions/tree_spec.js
spec/frontend/ide/stores/actions_spec.js
spec/frontend/ide/stores/extend_spec.js
spec/frontend/ide/stores/getters_spec.js
spec/frontend/ide/stores/integration_spec.js
## angry-bhabha ## angry-bhabha
spec/frontend/ide/stores/modules/branches/actions_spec.js spec/frontend/ide/stores/modules/branches/actions_spec.js
spec/frontend/ide/stores/modules/branches/mutations_spec.js spec/frontend/ide/stores/modules/branches/mutations_spec.js
......
...@@ -32,7 +32,7 @@ describe('RepoCommitSection', () => { ...@@ -32,7 +32,7 @@ describe('RepoCommitSection', () => {
}, },
}; };
const files = [file('file1'), file('file2')].map(f => const files = [file('file1'), file('file2')].map((f) =>
Object.assign(f, { Object.assign(f, {
type: 'blob', type: 'blob',
content: 'orginal content', content: 'orginal content',
...@@ -42,7 +42,7 @@ describe('RepoCommitSection', () => { ...@@ -42,7 +42,7 @@ describe('RepoCommitSection', () => {
store.state.currentBranch = 'master'; store.state.currentBranch = 'master';
store.state.changedFiles = []; store.state.changedFiles = [];
store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }]; store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }];
store.state.stagedFiles.forEach(f => store.state.stagedFiles.forEach((f) =>
Object.assign(f, { Object.assign(f, {
changed: true, changed: true,
staged: true, staged: true,
...@@ -50,7 +50,7 @@ describe('RepoCommitSection', () => { ...@@ -50,7 +50,7 @@ describe('RepoCommitSection', () => {
}), }),
); );
files.forEach(f => { files.forEach((f) => {
store.state.entries[f.path] = f; store.state.entries[f.path] = f;
}); });
} }
...@@ -105,9 +105,9 @@ describe('RepoCommitSection', () => { ...@@ -105,9 +105,9 @@ describe('RepoCommitSection', () => {
const allFiles = store.state.changedFiles.concat(store.state.stagedFiles); const allFiles = store.state.changedFiles.concat(store.state.stagedFiles);
const changedFileNames = wrapper const changedFileNames = wrapper
.findAll('.multi-file-commit-list > li') .findAll('.multi-file-commit-list > li')
.wrappers.map(x => x.text().trim()); .wrappers.map((x) => x.text().trim());
expect(changedFileNames).toEqual(allFiles.map(x => x.path)); expect(changedFileNames).toEqual(allFiles.map((x) => x.path));
}); });
it('does not show empty state', () => { it('does not show empty state', () => {
...@@ -141,7 +141,7 @@ describe('RepoCommitSection', () => { ...@@ -141,7 +141,7 @@ describe('RepoCommitSection', () => {
beforeEach(() => { beforeEach(() => {
setupDefaultState(); setupDefaultState();
store.state.changedFiles = store.state.stagedFiles.map(x => store.state.changedFiles = store.state.stagedFiles.map((x) =>
Object.assign(x, { staged: false }), Object.assign(x, { staged: false }),
); );
store.state.stagedFiles = []; store.state.stagedFiles = [];
......
...@@ -25,7 +25,7 @@ describe('RepoEditor', () => { ...@@ -25,7 +25,7 @@ describe('RepoEditor', () => {
let store; let store;
const waitForEditorSetup = () => const waitForEditorSetup = () =>
new Promise(resolve => { new Promise((resolve) => {
vm.$once('editorSetup', resolve); vm.$once('editorSetup', resolve);
}); });
...@@ -43,7 +43,7 @@ describe('RepoEditor', () => { ...@@ -43,7 +43,7 @@ describe('RepoEditor', () => {
vm.$mount(); vm.$mount();
}; };
const createOpenFile = path => { const createOpenFile = (path) => {
const origFile = store.state.openFiles[0]; const origFile = store.state.openFiles[0];
const newFile = { ...origFile, path, key: path, name: 'myfile.txt', content: 'hello world' }; const newFile = { ...origFile, path, key: path, name: 'myfile.txt', content: 'hello world' };
...@@ -91,7 +91,7 @@ describe('RepoEditor', () => { ...@@ -91,7 +91,7 @@ describe('RepoEditor', () => {
}); });
const findEditor = () => vm.$el.querySelector('.multi-file-editor-holder'); const findEditor = () => vm.$el.querySelector('.multi-file-editor-holder');
const changeViewMode = viewMode => const changeViewMode = (viewMode) =>
store.dispatch('editor/updateFileEditor', { path: vm.file.path, data: { viewMode } }); store.dispatch('editor/updateFileEditor', { path: vm.file.path, data: { viewMode } });
describe('default', () => { describe('default', () => {
...@@ -119,7 +119,7 @@ describe('RepoEditor', () => { ...@@ -119,7 +119,7 @@ describe('RepoEditor', () => {
expect(findEditor()).not.toHaveCss({ display: 'none' }); expect(findEditor()).not.toHaveCss({ display: 'none' });
}); });
it('renders only an edit tab', done => { it('renders only an edit tab', (done) => {
Vue.nextTick(() => { Vue.nextTick(() => {
const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li'); const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li');
...@@ -157,7 +157,7 @@ describe('RepoEditor', () => { ...@@ -157,7 +157,7 @@ describe('RepoEditor', () => {
mock.restore(); mock.restore();
}); });
it('renders an Edit and a Preview Tab', done => { it('renders an Edit and a Preview Tab', (done) => {
Vue.nextTick(() => { Vue.nextTick(() => {
const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li'); const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li');
...@@ -169,7 +169,7 @@ describe('RepoEditor', () => { ...@@ -169,7 +169,7 @@ describe('RepoEditor', () => {
}); });
}); });
it('renders markdown for tempFile', done => { it('renders markdown for tempFile', (done) => {
vm.file.tempFile = true; vm.file.tempFile = true;
vm.$nextTick() vm.$nextTick()
...@@ -202,7 +202,7 @@ describe('RepoEditor', () => { ...@@ -202,7 +202,7 @@ describe('RepoEditor', () => {
}); });
describe('when open file is binary and not raw', () => { describe('when open file is binary and not raw', () => {
beforeEach(done => { beforeEach((done) => {
vm.file.name = 'file.dat'; vm.file.name = 'file.dat';
vm.file.content = '🐱'; // non-ascii binary content vm.file.content = '🐱'; // non-ascii binary content
jest.spyOn(vm.editor, 'createInstance').mockImplementation(); jest.spyOn(vm.editor, 'createInstance').mockImplementation();
...@@ -227,7 +227,7 @@ describe('RepoEditor', () => { ...@@ -227,7 +227,7 @@ describe('RepoEditor', () => {
}); });
describe('createEditorInstance', () => { describe('createEditorInstance', () => {
it('calls createInstance when viewer is editor', done => { it('calls createInstance when viewer is editor', (done) => {
jest.spyOn(vm.editor, 'createInstance').mockImplementation(); jest.spyOn(vm.editor, 'createInstance').mockImplementation();
vm.createEditorInstance(); vm.createEditorInstance();
...@@ -239,7 +239,7 @@ describe('RepoEditor', () => { ...@@ -239,7 +239,7 @@ describe('RepoEditor', () => {
}); });
}); });
it('calls createDiffInstance when viewer is diff', done => { it('calls createDiffInstance when viewer is diff', (done) => {
vm.$store.state.viewer = 'diff'; vm.$store.state.viewer = 'diff';
jest.spyOn(vm.editor, 'createDiffInstance').mockImplementation(); jest.spyOn(vm.editor, 'createDiffInstance').mockImplementation();
...@@ -253,7 +253,7 @@ describe('RepoEditor', () => { ...@@ -253,7 +253,7 @@ describe('RepoEditor', () => {
}); });
}); });
it('calls createDiffInstance when viewer is a merge request diff', done => { it('calls createDiffInstance when viewer is a merge request diff', (done) => {
vm.$store.state.viewer = 'mrdiff'; vm.$store.state.viewer = 'mrdiff';
jest.spyOn(vm.editor, 'createDiffInstance').mockImplementation(); jest.spyOn(vm.editor, 'createDiffInstance').mockImplementation();
...@@ -354,7 +354,7 @@ describe('RepoEditor', () => { ...@@ -354,7 +354,7 @@ describe('RepoEditor', () => {
jest.spyOn(vm.editor, 'updateDiffView').mockImplementation(); jest.spyOn(vm.editor, 'updateDiffView').mockImplementation();
}); });
it('calls updateDimensions when panelResizing is false', done => { it('calls updateDimensions when panelResizing is false', (done) => {
vm.$store.state.panelResizing = true; vm.$store.state.panelResizing = true;
vm.$nextTick() vm.$nextTick()
...@@ -370,7 +370,7 @@ describe('RepoEditor', () => { ...@@ -370,7 +370,7 @@ describe('RepoEditor', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not call updateDimensions when panelResizing is true', done => { it('does not call updateDimensions when panelResizing is true', (done) => {
vm.$store.state.panelResizing = true; vm.$store.state.panelResizing = true;
vm.$nextTick(() => { vm.$nextTick(() => {
...@@ -381,7 +381,7 @@ describe('RepoEditor', () => { ...@@ -381,7 +381,7 @@ describe('RepoEditor', () => {
}); });
}); });
it('calls updateDimensions when rightPane is opened', done => { it('calls updateDimensions when rightPane is opened', (done) => {
vm.$store.state.rightPane.isOpen = true; vm.$store.state.rightPane.isOpen = true;
vm.$nextTick(() => { vm.$nextTick(() => {
...@@ -398,7 +398,7 @@ describe('RepoEditor', () => { ...@@ -398,7 +398,7 @@ describe('RepoEditor', () => {
expect(vm.$el.querySelector('.nav-links')).not.toBe(null); expect(vm.$el.querySelector('.nav-links')).not.toBe(null);
}); });
it('hides tabs in review mode', done => { it('hides tabs in review mode', (done) => {
vm.$store.state.currentActivityView = leftSidebarViews.review.name; vm.$store.state.currentActivityView = leftSidebarViews.review.name;
vm.$nextTick(() => { vm.$nextTick(() => {
...@@ -408,7 +408,7 @@ describe('RepoEditor', () => { ...@@ -408,7 +408,7 @@ describe('RepoEditor', () => {
}); });
}); });
it('hides tabs in commit mode', done => { it('hides tabs in commit mode', (done) => {
vm.$store.state.currentActivityView = leftSidebarViews.commit.name; vm.$store.state.currentActivityView = leftSidebarViews.commit.name;
vm.$nextTick(() => { vm.$nextTick(() => {
...@@ -420,7 +420,7 @@ describe('RepoEditor', () => { ...@@ -420,7 +420,7 @@ describe('RepoEditor', () => {
}); });
describe('when files view mode is preview', () => { describe('when files view mode is preview', () => {
beforeEach(done => { beforeEach((done) => {
jest.spyOn(vm.editor, 'updateDimensions').mockImplementation(); jest.spyOn(vm.editor, 'updateDimensions').mockImplementation();
changeViewMode(FILE_VIEW_MODE_PREVIEW); changeViewMode(FILE_VIEW_MODE_PREVIEW);
vm.file.name = 'myfile.md'; vm.file.name = 'myfile.md';
...@@ -452,7 +452,7 @@ describe('RepoEditor', () => { ...@@ -452,7 +452,7 @@ describe('RepoEditor', () => {
jest.spyOn(vm, 'shouldHideEditor', 'get').mockReturnValue(true); jest.spyOn(vm, 'shouldHideEditor', 'get').mockReturnValue(true);
}); });
it('does not fetch file information for temp entries', done => { it('does not fetch file information for temp entries', (done) => {
vm.file.tempFile = true; vm.file.tempFile = true;
vm.initEditor(); vm.initEditor();
...@@ -464,7 +464,7 @@ describe('RepoEditor', () => { ...@@ -464,7 +464,7 @@ describe('RepoEditor', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('is being initialised for files without content even if shouldHideEditor is `true`', done => { it('is being initialised for files without content even if shouldHideEditor is `true`', (done) => {
vm.file.content = ''; vm.file.content = '';
vm.file.raw = ''; vm.file.raw = '';
...@@ -479,7 +479,7 @@ describe('RepoEditor', () => { ...@@ -479,7 +479,7 @@ describe('RepoEditor', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not initialize editor for files already with content', done => { it('does not initialize editor for files already with content', (done) => {
vm.file.content = 'foo'; vm.file.content = 'foo';
vm.initEditor(); vm.initEditor();
...@@ -499,7 +499,7 @@ describe('RepoEditor', () => { ...@@ -499,7 +499,7 @@ describe('RepoEditor', () => {
jest.spyOn(vm, 'initEditor').mockImplementation(); jest.spyOn(vm, 'initEditor').mockImplementation();
}); });
it('calls removePendingTab when old file is pending', done => { it('calls removePendingTab when old file is pending', (done) => {
jest.spyOn(vm, 'shouldHideEditor', 'get').mockReturnValue(true); jest.spyOn(vm, 'shouldHideEditor', 'get').mockReturnValue(true);
jest.spyOn(vm, 'removePendingTab').mockImplementation(); jest.spyOn(vm, 'removePendingTab').mockImplementation();
...@@ -519,7 +519,7 @@ describe('RepoEditor', () => { ...@@ -519,7 +519,7 @@ describe('RepoEditor', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not call initEditor if the file did not change', done => { it('does not call initEditor if the file did not change', (done) => {
Vue.set(vm, 'file', vm.file); Vue.set(vm, 'file', vm.file);
vm.$nextTick() vm.$nextTick()
...@@ -530,7 +530,7 @@ describe('RepoEditor', () => { ...@@ -530,7 +530,7 @@ describe('RepoEditor', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('calls initEditor when file key is changed', done => { it('calls initEditor when file key is changed', (done) => {
expect(vm.initEditor).not.toHaveBeenCalled(); expect(vm.initEditor).not.toHaveBeenCalled();
Vue.set(vm, 'file', { Vue.set(vm, 'file', {
...@@ -552,7 +552,7 @@ describe('RepoEditor', () => { ...@@ -552,7 +552,7 @@ describe('RepoEditor', () => {
vm.getRawFileData.mockRestore(); vm.getRawFileData.mockRestore();
}); });
const createRemoteFile = name => ({ const createRemoteFile = (name) => ({
...file(name), ...file(name),
tmpFile: false, tmpFile: false,
}); });
...@@ -605,7 +605,7 @@ describe('RepoEditor', () => { ...@@ -605,7 +605,7 @@ describe('RepoEditor', () => {
}); });
describe('onPaste', () => { describe('onPaste', () => {
const setFileName = name => { const setFileName = (name) => {
Vue.set(vm, 'file', { Vue.set(vm, 'file', {
...vm.file, ...vm.file,
content: 'hello world\n', content: 'hello world\n',
...@@ -627,8 +627,8 @@ describe('RepoEditor', () => { ...@@ -627,8 +627,8 @@ describe('RepoEditor', () => {
); );
}; };
const watchState = watched => const watchState = (watched) =>
new Promise(resolve => { new Promise((resolve) => {
const unwatch = vm.$store.watch(watched, () => { const unwatch = vm.$store.watch(watched, () => {
unwatch(); unwatch();
resolve(); resolve();
...@@ -638,7 +638,7 @@ describe('RepoEditor', () => { ...@@ -638,7 +638,7 @@ describe('RepoEditor', () => {
// Pasting an image does a lot of things like using the FileReader API, // Pasting an image does a lot of things like using the FileReader API,
// so, waitForPromises isn't very reliable (and causes a flaky spec) // so, waitForPromises isn't very reliable (and causes a flaky spec)
// Read more about state.watch: https://vuex.vuejs.org/api/#watch // Read more about state.watch: https://vuex.vuejs.org/api/#watch
const waitForFileContentChange = () => watchState(s => s.entries['foo/bar.md'].content); const waitForFileContentChange = () => watchState((s) => s.entries['foo/bar.md'].content);
beforeEach(() => { beforeEach(() => {
setFileName('bar.md'); setFileName('bar.md');
......
...@@ -30,7 +30,7 @@ describe('RepoTabs', () => { ...@@ -30,7 +30,7 @@ describe('RepoTabs', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it('renders a list of tabs', done => { it('renders a list of tabs', (done) => {
store.state.openFiles[0].active = true; store.state.openFiles[0].active = true;
wrapper.vm.$nextTick(() => { wrapper.vm.$nextTick(() => {
......
...@@ -38,7 +38,7 @@ describe('~/ide/components/resizable_panel', () => { ...@@ -38,7 +38,7 @@ describe('~/ide/components/resizable_panel', () => {
}; };
const findResizer = () => wrapper.find(PanelResizer); const findResizer = () => wrapper.find(PanelResizer);
const findInlineStyle = () => wrapper.element.style.cssText; const findInlineStyle = () => wrapper.element.style.cssText;
const createInlineStyle = width => `width: ${width}px;`; const createInlineStyle = (width) => `width: ${width}px;`;
describe.each` describe.each`
props | showResizer | resizerSide | expectedStyle props | showResizer | resizerSide | expectedStyle
......
...@@ -44,9 +44,9 @@ describe('IDE shared/TokenedInput', () => { ...@@ -44,9 +44,9 @@ describe('IDE shared/TokenedInput', () => {
}); });
it('renders tokens', () => { it('renders tokens', () => {
const renderedTokens = getTokenElements(vm).map(x => x.textContent.trim()); const renderedTokens = getTokenElements(vm).map((x) => x.textContent.trim());
expect(renderedTokens).toEqual(TEST_TOKENS.map(x => x.label)); expect(renderedTokens).toEqual(TEST_TOKENS.map((x) => x.label));
}); });
it('renders input', () => { it('renders input', () => {
...@@ -54,7 +54,7 @@ describe('IDE shared/TokenedInput', () => { ...@@ -54,7 +54,7 @@ describe('IDE shared/TokenedInput', () => {
expect(vm.$refs.input).toHaveValue(TEST_VALUE); expect(vm.$refs.input).toHaveValue(TEST_VALUE);
}); });
it('renders placeholder, when tokens are empty', done => { it('renders placeholder, when tokens are empty', (done) => {
vm.tokens = []; vm.tokens = [];
vm.$nextTick() vm.$nextTick()
......
...@@ -67,7 +67,7 @@ describe('IDE TerminalSession', () => { ...@@ -67,7 +67,7 @@ describe('IDE TerminalSession', () => {
}); });
}); });
[STARTING, PENDING, RUNNING].forEach(status => { [STARTING, PENDING, RUNNING].forEach((status) => {
it(`show stop button when status is ${status}`, () => { it(`show stop button when status is ${status}`, () => {
state.session = { status }; state.session = { status };
factory(); factory();
...@@ -82,7 +82,7 @@ describe('IDE TerminalSession', () => { ...@@ -82,7 +82,7 @@ describe('IDE TerminalSession', () => {
}); });
}); });
[STOPPING, STOPPED].forEach(status => { [STOPPING, STOPPED].forEach((status) => {
it(`show stop button when status is ${status}`, () => { it(`show stop button when status is ${status}`, () => {
state.session = { status }; state.session = { status };
factory(); factory();
......
...@@ -17,7 +17,7 @@ describe('IDE TerminalControls', () => { ...@@ -17,7 +17,7 @@ describe('IDE TerminalControls', () => {
it('shows an up and down scroll button', () => { it('shows an up and down scroll button', () => {
factory(); factory();
expect(buttons.wrappers.map(x => x.props())).toEqual([ expect(buttons.wrappers.map((x) => x.props())).toEqual([
expect.objectContaining({ direction: 'up', disabled: true }), expect.objectContaining({ direction: 'up', disabled: true }),
expect.objectContaining({ direction: 'down', disabled: true }), expect.objectContaining({ direction: 'down', disabled: true }),
]); ]);
......
...@@ -31,7 +31,7 @@ describe('IDE Terminal', () => { ...@@ -31,7 +31,7 @@ describe('IDE Terminal', () => {
let wrapper; let wrapper;
let state; let state;
const factory = propsData => { const factory = (propsData) => {
const store = new Vuex.Store({ const store = new Vuex.Store({
state, state,
mutations: { mutations: {
...@@ -63,7 +63,7 @@ describe('IDE Terminal', () => { ...@@ -63,7 +63,7 @@ describe('IDE Terminal', () => {
}); });
describe('loading text', () => { describe('loading text', () => {
[STARTING, PENDING].forEach(status => { [STARTING, PENDING].forEach((status) => {
it(`shows when starting (${status})`, () => { it(`shows when starting (${status})`, () => {
factory({ status }); factory({ status });
...@@ -79,7 +79,7 @@ describe('IDE Terminal', () => { ...@@ -79,7 +79,7 @@ describe('IDE Terminal', () => {
expect(wrapper.find('.top-bar').text()).toBe('Stopping...'); expect(wrapper.find('.top-bar').text()).toBe('Stopping...');
}); });
[RUNNING, STOPPED].forEach(status => { [RUNNING, STOPPED].forEach((status) => {
it('hides when not loading', () => { it('hides when not loading', () => {
factory({ status }); factory({ status });
......
...@@ -26,7 +26,7 @@ describe('ide/components/terminal_sync/terminal_sync_status', () => { ...@@ -26,7 +26,7 @@ describe('ide/components/terminal_sync/terminal_sync_status', () => {
namespaced: true, namespaced: true,
state: moduleState, state: moduleState,
mutations: { mutations: {
[START_LOADING]: state => { [START_LOADING]: (state) => {
state.isLoading = true; state.isLoading = true;
}, },
}, },
......
...@@ -26,7 +26,7 @@ export const createMovedFile = (path, prevPath, content) => ...@@ -26,7 +26,7 @@ export const createMovedFile = (path, prevPath, content) =>
prevPath, prevPath,
}); });
export const createEntries = path => export const createEntries = (path) =>
path.split('/').reduce((acc, part, idx, parts) => { path.split('/').reduce((acc, part, idx, parts) => {
const parentPath = parts.slice(0, idx).join('/'); const parentPath = parts.slice(0, idx).join('/');
const fullPath = parentPath ? `${parentPath}/${part}` : part; const fullPath = parentPath ? `${parentPath}/${part}` : part;
......
...@@ -12,9 +12,9 @@ export const file = (name = 'name', id = name, type = '', parent = null) => ...@@ -12,9 +12,9 @@ export const file = (name = 'name', id = name, type = '', parent = null) =>
parentPath: parent ? parent.path : '', parentPath: parent ? parent.path : '',
}); });
export const createEntriesFromPaths = paths => export const createEntriesFromPaths = (paths) =>
paths paths
.map(path => ({ .map((path) => ({
name: pathUtils.basename(path), name: pathUtils.basename(path),
dir: pathUtils.dirname(path), dir: pathUtils.dirname(path),
ext: pathUtils.extname(path), ext: pathUtils.extname(path),
...@@ -30,7 +30,7 @@ export const createEntriesFromPaths = paths => ...@@ -30,7 +30,7 @@ export const createEntriesFromPaths = paths =>
}; };
}, {}); }, {});
export const createTriggerChangeAction = payload => ({ export const createTriggerChangeAction = (payload) => ({
type: 'triggerFilesChange', type: 'triggerFilesChange',
...(payload ? { payload } : {}), ...(payload ? { payload } : {}),
}); });
......
...@@ -4,7 +4,7 @@ import IdeRouter from '~/ide/ide_router_extension'; ...@@ -4,7 +4,7 @@ import IdeRouter from '~/ide/ide_router_extension';
jest.mock('vue-router'); jest.mock('vue-router');
describe('IDE overrides of VueRouter', () => { describe('IDE overrides of VueRouter', () => {
const paths = branch => [ const paths = (branch) => [
`${branch}`, `${branch}`,
`/${branch}`, `/${branch}`,
`/${branch}/-/`, `/${branch}/-/`,
...@@ -35,7 +35,7 @@ describe('IDE overrides of VueRouter', () => { ...@@ -35,7 +35,7 @@ describe('IDE overrides of VueRouter', () => {
${'test-#-hash'} | ${'test-%23-hash'} ${'test-#-hash'} | ${'test-%23-hash'}
${'test/hash#123'} | ${'test/hash%23123'} ${'test/hash#123'} | ${'test/hash%23123'}
`('finds project path when route is $path', ({ path, expected }) => { `('finds project path when route is $path', ({ path, expected }) => {
paths(path).forEach(route => { paths(path).forEach((route) => {
const expectedPath = route.replace(path, expected); const expectedPath = route.replace(path, expected);
router.push(route); router.push(route);
......
...@@ -32,7 +32,7 @@ describe('IDE router', () => { ...@@ -32,7 +32,7 @@ describe('IDE router', () => {
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}`,
].forEach(route => { ].forEach((route) => {
it(`finds project path when route is "${route}"`, () => { it(`finds project path when route is "${route}"`, () => {
router.push(route); router.push(route);
......
...@@ -81,7 +81,7 @@ describe('Multi-file editor library model', () => { ...@@ -81,7 +81,7 @@ describe('Multi-file editor library model', () => {
}); });
describe('onChange', () => { describe('onChange', () => {
it('calls callback on change', done => { it('calls callback on change', (done) => {
const spy = jest.fn(); const spy = jest.fn();
model.onChange(spy); model.onChange(spy);
......
...@@ -145,12 +145,12 @@ new file mode 100644 ...@@ -145,12 +145,12 @@ new file mode 100644
--- /dev/null --- /dev/null
+++ b/${PATH_LOREM} +++ b/${PATH_LOREM}
@@ -0,0 +1,${LINES.length} @@ @@ -0,0 +1,${LINES.length} @@
${LINES.map(line => `+${line}`).join('\n')} ${LINES.map((line) => `+${line}`).join('\n')}
diff --git "a/${PATH_IPSUM}" "b/${PATH_IPSUM}" diff --git "a/${PATH_IPSUM}" "b/${PATH_IPSUM}"
--- a/${PATH_IPSUM} --- a/${PATH_IPSUM}
+++ b/${PATH_IPSUM} +++ b/${PATH_IPSUM}
@@ -1,${LINES.length} +1,1 @@ @@ -1,${LINES.length} +1,1 @@
${LINES.map(line => `-${line}`).join('\n')} ${LINES.map((line) => `-${line}`).join('\n')}
+That's all folks! +That's all folks!
\\ No newline at end of file \\ No newline at end of file
`; `;
...@@ -167,10 +167,10 @@ ${LINES.map(line => `-${line}`).join('\n')} ...@@ -167,10 +167,10 @@ ${LINES.map(line => `-${line}`).join('\n')}
const deletedFiles = ['foo/bar/zed/test.md', 'foo/bar/zed/test2.md']; const deletedFiles = ['foo/bar/zed/test.md', 'foo/bar/zed/test2.md'];
const entries = deletedFiles.reduce((acc, path) => Object.assign(acc, createEntries(path)), {}); const entries = deletedFiles.reduce((acc, path) => Object.assign(acc, createEntries(path)), {});
const allDeleted = [...deletedFiles, 'foo/bar/zed', 'foo/bar']; const allDeleted = [...deletedFiles, 'foo/bar/zed', 'foo/bar'];
allDeleted.forEach(path => { allDeleted.forEach((path) => {
entries[path].deleted = true; entries[path].deleted = true;
}); });
const changedFiles = deletedFiles.map(x => entries[x]); const changedFiles = deletedFiles.map((x) => entries[x]);
const result = createDiff({ changedFiles, entries }); const result = createDiff({ changedFiles, entries });
......
...@@ -51,7 +51,7 @@ describe('IDE lib/create_file_diff', () => { ...@@ -51,7 +51,7 @@ describe('IDE lib/create_file_diff', () => {
const expectedHead = `diff --git "a/${PATH}" "b/${PATH}" const expectedHead = `diff --git "a/${PATH}" "b/${PATH}"
new file mode 100644`; new file mode 100644`;
const expectedChunkHead = lineCount => `--- /dev/null const expectedChunkHead = (lineCount) => `--- /dev/null
+++ b/${PATH} +++ b/${PATH}
@@ -0,0 +1,${lineCount} @@`; @@ -0,0 +1,${lineCount} @@`;
...@@ -86,7 +86,7 @@ ${expectedChunkHead(1)} ...@@ -86,7 +86,7 @@ ${expectedChunkHead(1)}
expect(result).toBe(`${expectedHead} expect(result).toBe(`${expectedHead}
${expectedChunkHead(TEXT_LINE_COUNT)} ${expectedChunkHead(TEXT_LINE_COUNT)}
${mapLines(TEXT, line => `+${line}`)} ${mapLines(TEXT, (line) => `+${line}`)}
`); `);
}); });
}); });
...@@ -95,7 +95,7 @@ ${mapLines(TEXT, line => `+${line}`)} ...@@ -95,7 +95,7 @@ ${mapLines(TEXT, line => `+${line}`)}
const expectedHead = `diff --git "a/${PATH}" "b/${PATH}" const expectedHead = `diff --git "a/${PATH}" "b/${PATH}"
deleted file mode 100644`; deleted file mode 100644`;
const expectedChunkHead = lineCount => `--- a/${PATH} const expectedChunkHead = (lineCount) => `--- a/${PATH}
+++ /dev/null +++ /dev/null
@@ -1,${lineCount} +0,0 @@`; @@ -1,${lineCount} +0,0 @@`;
...@@ -111,7 +111,7 @@ deleted file mode 100644`; ...@@ -111,7 +111,7 @@ deleted file mode 100644`;
expect(result).toBe(`${expectedHead} expect(result).toBe(`${expectedHead}
${expectedChunkHead(TEXT_LINE_COUNT)} ${expectedChunkHead(TEXT_LINE_COUNT)}
${mapLines(TEXT, line => `-${line}`)} ${mapLines(TEXT, (line) => `-${line}`)}
`); `);
}); });
}); });
......
...@@ -37,7 +37,7 @@ describe('Multi-file editor library dirty diff controller', () => { ...@@ -37,7 +37,7 @@ describe('Multi-file editor library dirty diff controller', () => {
}); });
describe('getDiffChangeType', () => { describe('getDiffChangeType', () => {
['added', 'removed', 'modified'].forEach(type => { ['added', 'removed', 'modified'].forEach((type) => {
it(`returns ${type}`, () => { it(`returns ${type}`, () => {
const change = { const change = {
[type]: true, [type]: true,
...@@ -49,7 +49,7 @@ describe('Multi-file editor library dirty diff controller', () => { ...@@ -49,7 +49,7 @@ describe('Multi-file editor library dirty diff controller', () => {
}); });
describe('getDecorator', () => { describe('getDecorator', () => {
['added', 'removed', 'modified'].forEach(type => { ['added', 'removed', 'modified'].forEach((type) => {
it(`returns with linesDecorationsClassName for ${type}`, () => { it(`returns with linesDecorationsClassName for ${type}`, () => {
const change = { const change = {
[type]: true, [type]: true,
......
...@@ -15,7 +15,7 @@ describe('Multi-file editor library', () => { ...@@ -15,7 +15,7 @@ describe('Multi-file editor library', () => {
let holder; let holder;
let store; let store;
const setNodeOffsetWidth = val => { const setNodeOffsetWidth = (val) => {
Object.defineProperty(instance.instance.getDomNode(), 'offsetWidth', { Object.defineProperty(instance.instance.getDomNode(), 'offsetWidth', {
get() { get() {
return val; return val;
......
...@@ -2,14 +2,14 @@ import { getRulesWithTraversal } from '~/ide/lib/editorconfig/parser'; ...@@ -2,14 +2,14 @@ import { getRulesWithTraversal } from '~/ide/lib/editorconfig/parser';
import { exampleConfigs, exampleFiles } from './mock_data'; import { exampleConfigs, exampleFiles } from './mock_data';
describe('~/ide/lib/editorconfig/parser', () => { describe('~/ide/lib/editorconfig/parser', () => {
const getExampleConfigContent = path => const getExampleConfigContent = (path) =>
Promise.resolve(exampleConfigs.find(x => x.path === path)?.content); Promise.resolve(exampleConfigs.find((x) => x.path === path)?.content);
describe('getRulesWithTraversal', () => { describe('getRulesWithTraversal', () => {
it.each(exampleFiles)( it.each(exampleFiles)(
'traverses through all editorconfig files in parent directories (until root=true is hit) and finds rules for this file (case %#)', 'traverses through all editorconfig files in parent directories (until root=true is hit) and finds rules for this file (case %#)',
({ path, rules }) => { ({ path, rules }) => {
return getRulesWithTraversal(path, getExampleConfigContent).then(result => { return getRulesWithTraversal(path, getExampleConfigContent).then((result) => {
expect(result).toEqual(rules); expect(result).toEqual(rules);
}); });
}, },
......
...@@ -14,7 +14,7 @@ const CODEOWNERS_MESSAGE = ...@@ -14,7 +14,7 @@ const CODEOWNERS_MESSAGE =
const CHANGED_MESSAGE = 'Things changed since you started editing'; const CHANGED_MESSAGE = 'Things changed since you started editing';
describe('~/ide/lib/errors', () => { describe('~/ide/lib/errors', () => {
const createResponseError = message => ({ const createResponseError = (message) => ({
response: { response: {
data: { data: {
message, message,
......
...@@ -3,7 +3,7 @@ import { decorateData } from '~/ide/stores/utils'; ...@@ -3,7 +3,7 @@ import { decorateData } from '~/ide/stores/utils';
const TEST_BLOB_DATA = { mimeType: 'test/mime' }; const TEST_BLOB_DATA = { mimeType: 'test/mime' };
const createEntries = paths => { const createEntries = (paths) => {
const createEntry = (acc, { path, type, children }) => { const createEntry = (acc, { path, type, children }) => {
const { name, parent } = splitParent(path); const { name, parent } = splitParent(path);
...@@ -15,7 +15,7 @@ const createEntries = paths => { ...@@ -15,7 +15,7 @@ const createEntries = paths => {
type, type,
parentPath: parent, parentPath: parent,
}), }),
tree: children.map(childName => expect.objectContaining({ name: childName })), tree: children.map((childName) => expect.objectContaining({ name: childName })),
...(type === 'blob' ? TEST_BLOB_DATA : {}), ...(type === 'blob' ? TEST_BLOB_DATA : {}),
}; };
...@@ -53,7 +53,7 @@ describe('IDE lib decorate files', () => { ...@@ -53,7 +53,7 @@ describe('IDE lib decorate files', () => {
const entryKeys = Object.keys(entries); const entryKeys = Object.keys(entries);
expect(entryKeys).toEqual(Object.keys(expectedEntries)); expect(entryKeys).toEqual(Object.keys(expectedEntries));
entryKeys.forEach(key => { entryKeys.forEach((key) => {
expect(entries[key]).toEqual(expectedEntries[key]); expect(entries[key]).toEqual(expectedEntries[key]);
}); });
......
...@@ -72,7 +72,7 @@ describe('ide/lib/mirror', () => { ...@@ -72,7 +72,7 @@ describe('ide/lib/mirror', () => {
}); });
const waitForConnection = (delay = SERVICE_DELAY) => { const waitForConnection = (delay = SERVICE_DELAY) => {
const wait = new Promise(resolve => { const wait = new Promise((resolve) => {
setTimeout(resolve, 10); setTimeout(resolve, 10);
}); });
...@@ -82,7 +82,7 @@ describe('ide/lib/mirror', () => { ...@@ -82,7 +82,7 @@ describe('ide/lib/mirror', () => {
}; };
const connectPass = () => waitForConnection().then(() => mockWebSocket.onopen()); const connectPass = () => waitForConnection().then(() => mockWebSocket.onopen());
const connectFail = () => waitForConnection().then(() => mockWebSocket.onerror()); const connectFail = () => waitForConnection().then(() => mockWebSocket.onerror());
const sendResponse = msg => { const sendResponse = (msg) => {
mockWebSocket.onmessage(msg); mockWebSocket.onmessage(msg);
}; };
......
...@@ -51,7 +51,7 @@ describe('IDE services', () => { ...@@ -51,7 +51,7 @@ describe('IDE services', () => {
raw: 'raw content', raw: 'raw content',
}; };
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(raw).toBe('content'); expect(raw).toBe('content');
}); });
}); });
...@@ -65,7 +65,7 @@ describe('IDE services', () => { ...@@ -65,7 +65,7 @@ describe('IDE services', () => {
raw: 'raw content', raw: 'raw content',
}; };
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(raw).toBe('raw content'); expect(raw).toBe('raw content');
}); });
}); });
...@@ -77,7 +77,7 @@ describe('IDE services', () => { ...@@ -77,7 +77,7 @@ describe('IDE services', () => {
raw: 'raw content', raw: 'raw content',
}; };
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(raw).toBe('raw content'); expect(raw).toBe('raw content');
}); });
}); });
...@@ -89,7 +89,7 @@ describe('IDE services', () => { ...@@ -89,7 +89,7 @@ describe('IDE services', () => {
raw: '', raw: '',
}; };
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(raw).toBe(''); expect(raw).toBe('');
}); });
}); });
...@@ -116,7 +116,7 @@ describe('IDE services', () => { ...@@ -116,7 +116,7 @@ describe('IDE services', () => {
}); });
it('sends a request to file.rawPath', () => { it('sends a request to file.rawPath', () => {
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(axios.get).toHaveBeenCalledWith(file.rawPath, { expect(axios.get).toHaveBeenCalledWith(file.rawPath, {
transformResponse: [expect.any(Function)], transformResponse: [expect.any(Function)],
}); });
...@@ -127,7 +127,7 @@ describe('IDE services', () => { ...@@ -127,7 +127,7 @@ describe('IDE services', () => {
it('returns arraybuffer for binary files', () => { it('returns arraybuffer for binary files', () => {
file.binary = true; file.binary = true;
return services.getRawFileData(file).then(raw => { return services.getRawFileData(file).then((raw) => {
expect(axios.get).toHaveBeenCalledWith(file.rawPath, { expect(axios.get).toHaveBeenCalledWith(file.rawPath, {
transformResponse: [expect.any(Function)], transformResponse: [expect.any(Function)],
responseType: 'arraybuffer', responseType: 'arraybuffer',
...@@ -161,7 +161,7 @@ describe('IDE services', () => { ...@@ -161,7 +161,7 @@ describe('IDE services', () => {
it('gives back file.baseRaw for files with that property present', () => { it('gives back file.baseRaw for files with that property present', () => {
file.baseRaw = TEST_FILE_CONTENTS; file.baseRaw = TEST_FILE_CONTENTS;
return services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then(content => { return services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then((content) => {
expect(content).toEqual(TEST_FILE_CONTENTS); expect(content).toEqual(TEST_FILE_CONTENTS);
}); });
}); });
...@@ -170,7 +170,7 @@ describe('IDE services', () => { ...@@ -170,7 +170,7 @@ describe('IDE services', () => {
file.tempFile = true; file.tempFile = true;
file.baseRaw = TEST_FILE_CONTENTS; file.baseRaw = TEST_FILE_CONTENTS;
return services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then(content => { return services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then((content) => {
expect(content).toEqual(TEST_FILE_CONTENTS); expect(content).toEqual(TEST_FILE_CONTENTS);
}); });
}); });
...@@ -207,7 +207,7 @@ describe('IDE services', () => { ...@@ -207,7 +207,7 @@ describe('IDE services', () => {
}); });
it('fetches file content', () => it('fetches file content', () =>
services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then(content => { services.getBaseRawFileData(file, TEST_PROJECT_ID, TEST_COMMIT_SHA).then((content) => {
expect(content).toEqual(TEST_FILE_CONTENTS); expect(content).toEqual(TEST_FILE_CONTENTS);
})); }));
}, },
...@@ -224,7 +224,7 @@ describe('IDE services', () => { ...@@ -224,7 +224,7 @@ describe('IDE services', () => {
Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } })); Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } }));
query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } })); query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } }));
return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then(response => { return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then((response) => {
expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } }); expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } });
expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID); expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID);
expect(query).toHaveBeenCalledWith({ expect(query).toHaveBeenCalledWith({
......
...@@ -189,7 +189,7 @@ describe('IDE store file actions', () => { ...@@ -189,7 +189,7 @@ describe('IDE store file actions', () => {
}); });
describe('call to service', () => { describe('call to service', () => {
const callExpectation = serviceCalled => { const callExpectation = (serviceCalled) => {
store.dispatch('getFileData', { path: localFile.path }); store.dispatch('getFileData', { path: localFile.path });
if (serviceCalled) { if (serviceCalled) {
...@@ -422,11 +422,11 @@ describe('IDE store file actions', () => { ...@@ -422,11 +422,11 @@ describe('IDE store file actions', () => {
loadingWhenGettingRawData = undefined; loadingWhenGettingRawData = undefined;
loadingWhenGettingBaseRawData = undefined; loadingWhenGettingBaseRawData = undefined;
jest.spyOn(service, 'getRawFileData').mockImplementation(f => { jest.spyOn(service, 'getRawFileData').mockImplementation((f) => {
loadingWhenGettingRawData = f.loading; loadingWhenGettingRawData = f.loading;
return Promise.resolve('raw'); return Promise.resolve('raw');
}); });
jest.spyOn(service, 'getBaseRawFileData').mockImplementation(f => { jest.spyOn(service, 'getBaseRawFileData').mockImplementation((f) => {
loadingWhenGettingBaseRawData = f.loading; loadingWhenGettingBaseRawData = f.loading;
return Promise.resolve('rawBase'); return Promise.resolve('rawBase');
}); });
...@@ -743,7 +743,7 @@ describe('IDE store file actions', () => { ...@@ -743,7 +743,7 @@ describe('IDE store file actions', () => {
}); });
it('returns true when opened', () => { it('returns true when opened', () => {
return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then(added => { return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then((added) => {
expect(added).toBe(true); expect(added).toBe(true);
}); });
}); });
...@@ -755,7 +755,7 @@ describe('IDE store file actions', () => { ...@@ -755,7 +755,7 @@ describe('IDE store file actions', () => {
key: `pending-${f.key}`, key: `pending-${f.key}`,
}); });
return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then(added => { return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then((added) => {
expect(added).toBe(false); expect(added).toBe(false);
}); });
}); });
......
...@@ -49,7 +49,7 @@ describe('IDE store merge request actions', () => { ...@@ -49,7 +49,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, mockData); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, mockData);
}); });
it('calls getProjectMergeRequests service method', done => { it('calls getProjectMergeRequests service method', (done) => {
store store
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' })
.then(() => { .then(() => {
...@@ -66,7 +66,7 @@ describe('IDE store merge request actions', () => { ...@@ -66,7 +66,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('sets the "Merge Request" Object', done => { it('sets the "Merge Request" Object', (done) => {
store store
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' })
.then(() => { .then(() => {
...@@ -78,7 +78,7 @@ describe('IDE store merge request actions', () => { ...@@ -78,7 +78,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('sets "Current Merge Request" object to the most recent MR', done => { it('sets "Current Merge Request" object to the most recent MR', (done) => {
store store
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' })
.then(() => { .then(() => {
...@@ -88,7 +88,7 @@ describe('IDE store merge request actions', () => { ...@@ -88,7 +88,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does nothing if user cannot read MRs', done => { it('does nothing if user cannot read MRs', (done) => {
store.state.projects[TEST_PROJECT].userPermissions[PERMISSION_READ_MR] = false; store.state.projects[TEST_PROJECT].userPermissions[PERMISSION_READ_MR] = false;
store store
...@@ -108,7 +108,7 @@ describe('IDE store merge request actions', () => { ...@@ -108,7 +108,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, []); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, []);
}); });
it('does not fail if there are no merge requests for current branch', done => { it('does not fail if there are no merge requests for current branch', (done) => {
store store
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'foo' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'foo' })
.then(() => { .then(() => {
...@@ -126,7 +126,7 @@ describe('IDE store merge request actions', () => { ...@@ -126,7 +126,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).networkError(); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).networkError();
}); });
it('flashes message, if error', done => { it('flashes message, if error', (done) => {
store store
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' })
.catch(() => { .catch(() => {
...@@ -149,7 +149,7 @@ describe('IDE store merge request actions', () => { ...@@ -149,7 +149,7 @@ describe('IDE store merge request actions', () => {
.reply(200, { title: 'mergerequest' }); .reply(200, { title: 'mergerequest' });
}); });
it('calls getProjectMergeRequestData service method', done => { it('calls getProjectMergeRequestData service method', (done) => {
store store
.dispatch('getMergeRequestData', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestData', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -160,7 +160,7 @@ describe('IDE store merge request actions', () => { ...@@ -160,7 +160,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('sets the Merge Request Object', done => { it('sets the Merge Request Object', (done) => {
store store
.dispatch('getMergeRequestData', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestData', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -180,7 +180,7 @@ describe('IDE store merge request actions', () => { ...@@ -180,7 +180,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1/).networkError(); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1/).networkError();
}); });
it('dispatches error action', done => { it('dispatches error action', (done) => {
const dispatch = jest.fn(); const dispatch = jest.fn();
getMergeRequestData( getMergeRequestData(
...@@ -224,7 +224,7 @@ describe('IDE store merge request actions', () => { ...@@ -224,7 +224,7 @@ describe('IDE store merge request actions', () => {
.reply(200, { title: 'mergerequest' }); .reply(200, { title: 'mergerequest' });
}); });
it('calls getProjectMergeRequestChanges service method', done => { it('calls getProjectMergeRequestChanges service method', (done) => {
store store
.dispatch('getMergeRequestChanges', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestChanges', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -235,7 +235,7 @@ describe('IDE store merge request actions', () => { ...@@ -235,7 +235,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('sets the Merge Request Changes Object', done => { it('sets the Merge Request Changes Object', (done) => {
store store
.dispatch('getMergeRequestChanges', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestChanges', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -253,7 +253,7 @@ describe('IDE store merge request actions', () => { ...@@ -253,7 +253,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/changes/).networkError(); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/changes/).networkError();
}); });
it('dispatches error action', done => { it('dispatches error action', (done) => {
const dispatch = jest.fn(); const dispatch = jest.fn();
getMergeRequestChanges( getMergeRequestChanges(
...@@ -296,7 +296,7 @@ describe('IDE store merge request actions', () => { ...@@ -296,7 +296,7 @@ describe('IDE store merge request actions', () => {
jest.spyOn(service, 'getProjectMergeRequestVersions'); jest.spyOn(service, 'getProjectMergeRequestVersions');
}); });
it('calls getProjectMergeRequestVersions service method', done => { it('calls getProjectMergeRequestVersions service method', (done) => {
store store
.dispatch('getMergeRequestVersions', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestVersions', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -307,7 +307,7 @@ describe('IDE store merge request actions', () => { ...@@ -307,7 +307,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('sets the Merge Request Versions Object', done => { it('sets the Merge Request Versions Object', (done) => {
store store
.dispatch('getMergeRequestVersions', { projectId: TEST_PROJECT, mergeRequestId: 1 }) .dispatch('getMergeRequestVersions', { projectId: TEST_PROJECT, mergeRequestId: 1 })
.then(() => { .then(() => {
...@@ -323,7 +323,7 @@ describe('IDE store merge request actions', () => { ...@@ -323,7 +323,7 @@ describe('IDE store merge request actions', () => {
mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/versions/).networkError(); mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/versions/).networkError();
}); });
it('dispatches error action', done => { it('dispatches error action', (done) => {
const dispatch = jest.fn(); const dispatch = jest.fn();
getMergeRequestVersions( getMergeRequestVersions(
...@@ -422,7 +422,7 @@ describe('IDE store merge request actions', () => { ...@@ -422,7 +422,7 @@ describe('IDE store merge request actions', () => {
); );
}); });
it('dispatches actions for merge request data', done => { it('dispatches actions for merge request data', (done) => {
openMergeRequest({ state: store.state, dispatch: store.dispatch, getters: mockGetters }, mr) openMergeRequest({ state: store.state, dispatch: store.dispatch, getters: mockGetters }, mr)
.then(() => { .then(() => {
expect(store.dispatch.mock.calls).toEqual([ expect(store.dispatch.mock.calls).toEqual([
...@@ -451,7 +451,7 @@ describe('IDE store merge request actions', () => { ...@@ -451,7 +451,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('updates activity bar view and gets file data, if changes are found', done => { it('updates activity bar view and gets file data, if changes are found', (done) => {
store.state.entries.foo = { store.state.entries.foo = {
type: 'blob', type: 'blob',
}; };
...@@ -490,7 +490,7 @@ describe('IDE store merge request actions', () => { ...@@ -490,7 +490,7 @@ describe('IDE store merge request actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('flashes message, if error', done => { it('flashes message, if error', (done) => {
store.dispatch.mockRejectedValue(); store.dispatch.mockRejectedValue();
openMergeRequest(store, mr) openMergeRequest(store, mr)
......
...@@ -53,7 +53,7 @@ describe('IDE store project actions', () => { ...@@ -53,7 +53,7 @@ describe('IDE store project actions', () => {
}); });
}); });
it('calls the service', done => { it('calls the service', (done) => {
store store
.dispatch('refreshLastCommitData', { .dispatch('refreshLastCommitData', {
projectId: store.state.currentProjectId, projectId: store.state.currentProjectId,
...@@ -67,7 +67,7 @@ describe('IDE store project actions', () => { ...@@ -67,7 +67,7 @@ describe('IDE store project actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('commits getBranchData', done => { it('commits getBranchData', (done) => {
testAction( testAction(
refreshLastCommitData, refreshLastCommitData,
{ {
...@@ -94,7 +94,7 @@ describe('IDE store project actions', () => { ...@@ -94,7 +94,7 @@ describe('IDE store project actions', () => {
}); });
describe('showBranchNotFoundError', () => { describe('showBranchNotFoundError', () => {
it('dispatches setErrorMessage', done => { it('dispatches setErrorMessage', (done) => {
testAction( testAction(
showBranchNotFoundError, showBranchNotFoundError,
'master', 'master',
...@@ -123,7 +123,7 @@ describe('IDE store project actions', () => { ...@@ -123,7 +123,7 @@ describe('IDE store project actions', () => {
jest.spyOn(api, 'createBranch').mockResolvedValue(); jest.spyOn(api, 'createBranch').mockResolvedValue();
}); });
it('calls API', done => { it('calls API', (done) => {
createNewBranchFromDefault( createNewBranchFromDefault(
{ {
state: { state: {
...@@ -148,7 +148,7 @@ describe('IDE store project actions', () => { ...@@ -148,7 +148,7 @@ describe('IDE store project actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('clears error message', done => { it('clears error message', (done) => {
const dispatchSpy = jest.fn().mockName('dispatch'); const dispatchSpy = jest.fn().mockName('dispatch');
createNewBranchFromDefault( createNewBranchFromDefault(
...@@ -172,7 +172,7 @@ describe('IDE store project actions', () => { ...@@ -172,7 +172,7 @@ describe('IDE store project actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('reloads window', done => { it('reloads window', (done) => {
createNewBranchFromDefault( createNewBranchFromDefault(
{ {
state: { state: {
...@@ -196,7 +196,7 @@ describe('IDE store project actions', () => { ...@@ -196,7 +196,7 @@ describe('IDE store project actions', () => {
}); });
describe('loadEmptyBranch', () => { describe('loadEmptyBranch', () => {
it('creates a blank tree and sets loading state to false', done => { it('creates a blank tree and sets loading state to false', (done) => {
testAction( testAction(
loadEmptyBranch, loadEmptyBranch,
{ projectId: TEST_PROJECT_ID, branchId: 'master' }, { projectId: TEST_PROJECT_ID, branchId: 'master' },
...@@ -213,7 +213,7 @@ describe('IDE store project actions', () => { ...@@ -213,7 +213,7 @@ describe('IDE store project actions', () => {
); );
}); });
it('does nothing, if tree already exists', done => { it('does nothing, if tree already exists', (done) => {
const trees = { [`${TEST_PROJECT_ID}/master`]: [] }; const trees = { [`${TEST_PROJECT_ID}/master`]: [] };
testAction( testAction(
...@@ -279,7 +279,7 @@ describe('IDE store project actions', () => { ...@@ -279,7 +279,7 @@ describe('IDE store project actions', () => {
const branchId = '123-lorem'; const branchId = '123-lorem';
const ref = 'abcd2322'; const ref = 'abcd2322';
it('when empty repo, loads empty branch', done => { it('when empty repo, loads empty branch', (done) => {
const mockGetters = { emptyRepo: true }; const mockGetters = { emptyRepo: true };
testAction( testAction(
...@@ -292,13 +292,13 @@ describe('IDE store project actions', () => { ...@@ -292,13 +292,13 @@ describe('IDE store project actions', () => {
); );
}); });
it('when branch already exists, does nothing', done => { it('when branch already exists, does nothing', (done) => {
store.state.projects[projectId].branches[branchId] = {}; store.state.projects[projectId].branches[branchId] = {};
testAction(loadBranch, { projectId, branchId }, store.state, [], [], done); testAction(loadBranch, { projectId, branchId }, store.state, [], [], done);
}); });
it('fetches branch data', done => { it('fetches branch data', (done) => {
const mockGetters = { findBranch: () => ({ commit: { id: ref } }) }; const mockGetters = { findBranch: () => ({ commit: { id: ref } }) };
jest.spyOn(store, 'dispatch').mockResolvedValue(); jest.spyOn(store, 'dispatch').mockResolvedValue();
...@@ -317,7 +317,7 @@ describe('IDE store project actions', () => { ...@@ -317,7 +317,7 @@ describe('IDE store project actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('shows an error if branch can not be fetched', done => { it('shows an error if branch can not be fetched', (done) => {
jest.spyOn(store, 'dispatch').mockReturnValue(Promise.reject()); jest.spyOn(store, 'dispatch').mockReturnValue(Promise.reject());
loadBranch(store, { projectId, branchId }) loadBranch(store, { projectId, branchId })
...@@ -356,7 +356,7 @@ describe('IDE store project actions', () => { ...@@ -356,7 +356,7 @@ describe('IDE store project actions', () => {
jest.spyOn(store, 'dispatch').mockResolvedValue(); jest.spyOn(store, 'dispatch').mockResolvedValue();
}); });
it('dispatches branch actions', done => { it('dispatches branch actions', (done) => {
openBranch(store, branch) openBranch(store, branch)
.then(() => { .then(() => {
expect(store.dispatch.mock.calls).toEqual([ expect(store.dispatch.mock.calls).toEqual([
...@@ -375,9 +375,9 @@ describe('IDE store project actions', () => { ...@@ -375,9 +375,9 @@ describe('IDE store project actions', () => {
jest.spyOn(store, 'dispatch').mockReturnValue(Promise.reject()); jest.spyOn(store, 'dispatch').mockReturnValue(Promise.reject());
}); });
it('dispatches correct branch actions', done => { it('dispatches correct branch actions', (done) => {
openBranch(store, branch) openBranch(store, branch)
.then(val => { .then((val) => {
expect(store.dispatch.mock.calls).toEqual([ expect(store.dispatch.mock.calls).toEqual([
['setCurrentBranchId', branchId], ['setCurrentBranchId', branchId],
['loadBranch', { projectId, branchId }], ['loadBranch', { projectId, branchId }],
......
...@@ -68,7 +68,7 @@ describe('Multi-file store tree actions', () => { ...@@ -68,7 +68,7 @@ describe('Multi-file store tree actions', () => {
); );
}); });
it('adds data into tree', done => { it('adds data into tree', (done) => {
store store
.dispatch('getFiles', basicCallParameters) .dispatch('getFiles', basicCallParameters)
.then(() => { .then(() => {
...@@ -93,7 +93,7 @@ describe('Multi-file store tree actions', () => { ...@@ -93,7 +93,7 @@ describe('Multi-file store tree actions', () => {
}); });
describe('error', () => { describe('error', () => {
it('dispatches error action', done => { it('dispatches error action', (done) => {
const dispatch = jest.fn(); const dispatch = jest.fn();
store.state.projects = { store.state.projects = {
...@@ -148,7 +148,7 @@ describe('Multi-file store tree actions', () => { ...@@ -148,7 +148,7 @@ describe('Multi-file store tree actions', () => {
store.state.entries[tree.path] = tree; store.state.entries[tree.path] = tree;
}); });
it('toggles the tree open', done => { it('toggles the tree open', (done) => {
store store
.dispatch('toggleTreeOpen', tree.path) .dispatch('toggleTreeOpen', tree.path)
.then(() => { .then(() => {
...@@ -174,7 +174,7 @@ describe('Multi-file store tree actions', () => { ...@@ -174,7 +174,7 @@ describe('Multi-file store tree actions', () => {
Object.assign(store.state.entries, createEntriesFromPaths(paths)); Object.assign(store.state.entries, createEntriesFromPaths(paths));
}); });
it('opens the parents', done => { it('opens the parents', (done) => {
testAction( testAction(
showTreeEntry, showTreeEntry,
'grandparent/parent/child.txt', 'grandparent/parent/child.txt',
...@@ -187,7 +187,7 @@ describe('Multi-file store tree actions', () => { ...@@ -187,7 +187,7 @@ describe('Multi-file store tree actions', () => {
}); });
describe('setDirectoryData', () => { describe('setDirectoryData', () => {
it('sets tree correctly if there are no opened files yet', done => { it('sets tree correctly if there are no opened files yet', (done) => {
const treeFile = file({ name: 'README.md' }); const treeFile = file({ name: 'README.md' });
store.state.trees['abcproject/master'] = {}; store.state.trees['abcproject/master'] = {};
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ describe('ide/stores/extend', () => { ...@@ -15,7 +15,7 @@ describe('ide/stores/extend', () => {
store = {}; store = {};
el = {}; el = {};
[terminalPlugin, terminalSyncPlugin].forEach(x => { [terminalPlugin, terminalSyncPlugin].forEach((x) => {
const plugin = jest.fn(); const plugin = jest.fn();
x.mockImplementation(() => plugin); x.mockImplementation(() => plugin);
...@@ -28,7 +28,7 @@ describe('ide/stores/extend', () => { ...@@ -28,7 +28,7 @@ describe('ide/stores/extend', () => {
terminalSyncPlugin.mockClear(); terminalSyncPlugin.mockClear();
}); });
const withGonFeatures = features => { const withGonFeatures = (features) => {
global.gon = { ...global.gon, features }; global.gon = { ...global.gon, features };
}; };
......
...@@ -407,7 +407,7 @@ describe('IDE store getters', () => { ...@@ -407,7 +407,7 @@ describe('IDE store getters', () => {
${'canCreateMergeRequests'} | ${'createMergeRequestIn'} ${'canCreateMergeRequests'} | ${'createMergeRequestIn'}
${'canPushCode'} | ${'pushCode'} ${'canPushCode'} | ${'pushCode'}
`('$getterName', ({ getterName, permissionKey }) => { `('$getterName', ({ getterName, permissionKey }) => {
it.each([true, false])('finds permission for current project (%s)', val => { it.each([true, false])('finds permission for current project (%s)', (val) => {
localState.projects[TEST_PROJECT_ID] = { localState.projects[TEST_PROJECT_ID] = {
userPermissions: { userPermissions: {
[permissionKey]: val, [permissionKey]: val,
......
...@@ -84,7 +84,7 @@ describe('IDE store integration', () => { ...@@ -84,7 +84,7 @@ describe('IDE store integration', () => {
store.dispatch('commit/updateFilesAfterCommit', { data: {} }); store.dispatch('commit/updateFilesAfterCommit', { data: {} });
expect(store.state.entries[TEST_PATH]).toEqual(expected); expect(store.state.entries[TEST_PATH]).toEqual(expected);
expect(store.state.entries[TEST_PATH_DIR].tree.find(x => x.path === TEST_PATH)).toEqual( expect(store.state.entries[TEST_PATH_DIR].tree.find((x) => x.path === TEST_PATH)).toEqual(
expected, expected,
); );
}); });
......
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