Commit 52907ac2 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 32 files - 65 of 73

Part of our prettier migration; changing the arrow-parens style.
parent d4a8b730
export const resetStore = store => {
export const resetStore = (store) => {
store.replaceState({
notes: [],
targetNoteHash: null,
......
......@@ -34,7 +34,7 @@ describe('Discussion navigation mixin', () => {
setHTMLFixture(
[...'abcde']
.map(
id =>
(id) =>
`<ul class="notes" data-discussion-id="${id}"></ul>
<div class="discussion" data-discussion-id="${id}"></div>`,
)
......
......@@ -127,7 +127,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
jest.spyOn(notes, 'renderNote');
$('.js-comment-button').on('click', e => {
$('.js-comment-button').on('click', (e) => {
const $form = $(this);
e.preventDefault();
notes.addNote($form, {});
......@@ -550,7 +550,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
expect($notesContainer.find('.note.being-posted').length).toBeGreaterThan(0);
});
it('should remove placeholder note when new comment is done posting', done => {
it('should remove placeholder note when new comment is done posting', (done) => {
mockNotesPost();
$('.js-comment-button').click();
......@@ -562,7 +562,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
});
describe('postComment', () => {
it('disables the submit button', done => {
it('disables the submit button', (done) => {
const $submitButton = $form.find('.js-comment-submit-button');
expect($submitButton).not.toBeDisabled();
......@@ -585,7 +585,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
});
});
it('should show actual note element when new comment is done posting', done => {
it('should show actual note element when new comment is done posting', (done) => {
mockNotesPost();
$('.js-comment-button').click();
......@@ -596,7 +596,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
});
});
it('should reset Form when new comment is done posting', done => {
it('should reset Form when new comment is done posting', (done) => {
mockNotesPost();
$('.js-comment-button').click();
......@@ -607,7 +607,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
});
});
it('should show flash error message when new comment failed to be posted', done => {
it('should show flash error message when new comment failed to be posted', (done) => {
mockNotesPostError();
jest.spyOn(notes, 'addFlash');
......@@ -658,7 +658,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
$form.find('textarea.js-note-text').val(sampleComment);
});
it('should remove quick action placeholder when comment with quick actions is done posting', done => {
it('should remove quick action placeholder when comment with quick actions is done posting', (done) => {
jest.spyOn(gl.awardsHandler, 'addAwardToEmojiBar');
$('.js-comment-button').click();
......@@ -693,7 +693,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
$form.find('textarea.js-note-text').val(sampleComment);
});
it('should show message placeholder including lines starting with slash', done => {
it('should show message placeholder including lines starting with slash', (done) => {
$('.js-comment-button').click();
expect($notesContainer.find('.note.being-posted').length).toEqual(1); // Placeholder shown
......@@ -731,7 +731,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
$form.find('textarea.js-note-text').html(sampleComment);
});
it('should not render a script tag', done => {
it('should not render a script tag', (done) => {
$('.js-comment-button').click();
setImmediate(() => {
......
......@@ -53,7 +53,7 @@ describe('Actions Notes Store', () => {
});
describe('setNotesData', () => {
it('should set received notes data', done => {
it('should set received notes data', (done) => {
testAction(
actions.setNotesData,
notesDataMock,
......@@ -66,7 +66,7 @@ describe('Actions Notes Store', () => {
});
describe('setNoteableData', () => {
it('should set received issue data', done => {
it('should set received issue data', (done) => {
testAction(
actions.setNoteableData,
noteableDataMock,
......@@ -79,7 +79,7 @@ describe('Actions Notes Store', () => {
});
describe('setUserData', () => {
it('should set received user data', done => {
it('should set received user data', (done) => {
testAction(
actions.setUserData,
userDataMock,
......@@ -92,7 +92,7 @@ describe('Actions Notes Store', () => {
});
describe('setLastFetchedAt', () => {
it('should set received timestamp', done => {
it('should set received timestamp', (done) => {
testAction(
actions.setLastFetchedAt,
'timestamp',
......@@ -105,7 +105,7 @@ describe('Actions Notes Store', () => {
});
describe('setInitialNotes', () => {
it('should set initial notes', done => {
it('should set initial notes', (done) => {
testAction(
actions.setInitialNotes,
[individualNote],
......@@ -118,7 +118,7 @@ describe('Actions Notes Store', () => {
});
describe('setTargetNoteHash', () => {
it('should set target note hash', done => {
it('should set target note hash', (done) => {
testAction(
actions.setTargetNoteHash,
'hash',
......@@ -131,7 +131,7 @@ describe('Actions Notes Store', () => {
});
describe('toggleDiscussion', () => {
it('should toggle discussion', done => {
it('should toggle discussion', (done) => {
testAction(
actions.toggleDiscussion,
{ discussionId: discussionMock.id },
......@@ -144,7 +144,7 @@ describe('Actions Notes Store', () => {
});
describe('expandDiscussion', () => {
it('should expand discussion', done => {
it('should expand discussion', (done) => {
testAction(
actions.expandDiscussion,
{ discussionId: discussionMock.id },
......@@ -157,7 +157,7 @@ describe('Actions Notes Store', () => {
});
describe('collapseDiscussion', () => {
it('should commit collapse discussion', done => {
it('should commit collapse discussion', (done) => {
testAction(
actions.collapseDiscussion,
{ discussionId: discussionMock.id },
......@@ -175,7 +175,7 @@ describe('Actions Notes Store', () => {
});
describe('closeMergeRequest', () => {
it('sets state as closed', done => {
it('sets state as closed', (done) => {
store
.dispatch('closeIssuable', { notesData: { closeIssuePath: '' } })
.then(() => {
......@@ -188,7 +188,7 @@ describe('Actions Notes Store', () => {
});
describe('reopenMergeRequest', () => {
it('sets state as reopened', done => {
it('sets state as reopened', (done) => {
store
.dispatch('reopenIssuable', { notesData: { reopenIssuePath: '' } })
.then(() => {
......@@ -203,7 +203,7 @@ describe('Actions Notes Store', () => {
describe('emitStateChangedEvent', () => {
it('emits an event on the document', () => {
document.addEventListener('issuable_vue_app:change', event => {
document.addEventListener('issuable_vue_app:change', (event) => {
expect(event.detail.data).toEqual({ id: '1', state: 'closed' });
expect(event.detail.isClosed).toEqual(false);
});
......@@ -213,7 +213,7 @@ describe('Actions Notes Store', () => {
});
describe('toggleStateButtonLoading', () => {
it('should set loading as true', done => {
it('should set loading as true', (done) => {
testAction(
actions.toggleStateButtonLoading,
true,
......@@ -224,7 +224,7 @@ describe('Actions Notes Store', () => {
);
});
it('should set loading as false', done => {
it('should set loading as false', (done) => {
testAction(
actions.toggleStateButtonLoading,
false,
......@@ -237,11 +237,11 @@ describe('Actions Notes Store', () => {
});
describe('toggleIssueLocalState', () => {
it('sets issue state as closed', done => {
it('sets issue state as closed', (done) => {
testAction(actions.toggleIssueLocalState, 'closed', {}, [{ type: 'CLOSE_ISSUE' }], [], done);
});
it('sets issue state as reopened', done => {
it('sets issue state as reopened', (done) => {
testAction(
actions.toggleIssueLocalState,
'reopened',
......@@ -297,7 +297,7 @@ describe('Actions Notes Store', () => {
});
describe('poll', () => {
beforeEach(done => {
beforeEach((done) => {
axiosMock
.onGet(notesDataMock.notesPath)
.reply(200, { notes: [], last_fetched_at: '123456' }, { 'poll-interval': '1000' });
......@@ -305,13 +305,13 @@ describe('Actions Notes Store', () => {
store.dispatch('setNotesData', notesDataMock).then(done).catch(done.fail);
});
it('calls service with last fetched state', done => {
it('calls service with last fetched state', (done) => {
store
.dispatch('poll')
.then(() => {
jest.advanceTimersByTime(2);
})
.then(() => new Promise(resolve => requestAnimationFrame(resolve)))
.then(() => new Promise((resolve) => requestAnimationFrame(resolve)))
.then(() => {
expect(store.state.lastFetchedAt).toBe('123456');
......@@ -319,7 +319,7 @@ describe('Actions Notes Store', () => {
})
.then(
() =>
new Promise(resolve => {
new Promise((resolve) => {
requestAnimationFrame(resolve);
}),
)
......@@ -337,7 +337,7 @@ describe('Actions Notes Store', () => {
});
describe('setNotesFetchedState', () => {
it('should set notes fetched state', done => {
it('should set notes fetched state', (done) => {
testAction(
actions.setNotesFetchedState,
true,
......@@ -364,7 +364,7 @@ describe('Actions Notes Store', () => {
document.body.setAttribute('data-page', '');
});
it('commits DELETE_NOTE and dispatches updateMergeRequestWidget', done => {
it('commits DELETE_NOTE and dispatches updateMergeRequestWidget', (done) => {
const note = { path: endpoint, id: 1 };
testAction(
......@@ -389,7 +389,7 @@ describe('Actions Notes Store', () => {
);
});
it('dispatches removeDiscussionsFromDiff on merge request page', done => {
it('dispatches removeDiscussionsFromDiff on merge request page', (done) => {
const note = { path: endpoint, id: 1 };
document.body.setAttribute('data-page', 'projects:merge_requests:show');
......@@ -435,7 +435,7 @@ describe('Actions Notes Store', () => {
document.body.setAttribute('data-page', '');
});
it('dispatches removeNote', done => {
it('dispatches removeNote', (done) => {
const note = { path: endpoint, id: 1 };
testAction(
......@@ -468,7 +468,7 @@ describe('Actions Notes Store', () => {
axiosMock.onAny().reply(200, res);
});
it('commits ADD_NEW_NOTE and dispatches updateMergeRequestWidget', done => {
it('commits ADD_NEW_NOTE and dispatches updateMergeRequestWidget', (done) => {
testAction(
actions.createNewNote,
{ endpoint: `${TEST_HOST}`, data: {} },
......@@ -504,7 +504,7 @@ describe('Actions Notes Store', () => {
axiosMock.onAny().replyOnce(200, res);
});
it('does not commit ADD_NEW_NOTE or dispatch updateMergeRequestWidget', done => {
it('does not commit ADD_NEW_NOTE or dispatch updateMergeRequestWidget', (done) => {
testAction(
actions.createNewNote,
{ endpoint: `${TEST_HOST}`, data: {} },
......@@ -527,7 +527,7 @@ describe('Actions Notes Store', () => {
});
describe('as note', () => {
it('commits UPDATE_NOTE and dispatches updateMergeRequestWidget', done => {
it('commits UPDATE_NOTE and dispatches updateMergeRequestWidget', (done) => {
testAction(
actions.toggleResolveNote,
{ endpoint: `${TEST_HOST}`, isResolved: true, discussion: false },
......@@ -552,7 +552,7 @@ describe('Actions Notes Store', () => {
});
describe('as discussion', () => {
it('commits UPDATE_DISCUSSION and dispatches updateMergeRequestWidget', done => {
it('commits UPDATE_DISCUSSION and dispatches updateMergeRequestWidget', (done) => {
testAction(
actions.toggleResolveNote,
{ endpoint: `${TEST_HOST}`, isResolved: true, discussion: true },
......@@ -588,7 +588,7 @@ describe('Actions Notes Store', () => {
});
describe('setCommentsDisabled', () => {
it('should set comments disabled state', done => {
it('should set comments disabled state', (done) => {
testAction(
actions.setCommentsDisabled,
true,
......@@ -601,7 +601,7 @@ describe('Actions Notes Store', () => {
});
describe('updateResolvableDiscussionsCounts', () => {
it('commits UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', done => {
it('commits UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', (done) => {
testAction(
actions.updateResolvableDiscussionsCounts,
null,
......@@ -614,7 +614,7 @@ describe('Actions Notes Store', () => {
});
describe('convertToDiscussion', () => {
it('commits CONVERT_TO_DISCUSSION with noteId', done => {
it('commits CONVERT_TO_DISCUSSION with noteId', (done) => {
const noteId = 'dummy-note-id';
testAction(
actions.convertToDiscussion,
......@@ -718,7 +718,7 @@ describe('Actions Notes Store', () => {
describe('replyToDiscussion', () => {
const payload = { endpoint: TEST_HOST, data: {} };
it('updates discussion if response contains disussion', done => {
it('updates discussion if response contains disussion', (done) => {
const discussion = { notes: [] };
axiosMock.onAny().reply(200, { discussion });
......@@ -738,7 +738,7 @@ describe('Actions Notes Store', () => {
);
});
it('adds a reply to a discussion', done => {
it('adds a reply to a discussion', (done) => {
const res = {};
axiosMock.onAny().reply(200, res);
......@@ -756,7 +756,7 @@ describe('Actions Notes Store', () => {
});
describe('removeConvertedDiscussion', () => {
it('commits CONVERT_TO_DISCUSSION with noteId', done => {
it('commits CONVERT_TO_DISCUSSION with noteId', (done) => {
const noteId = 'dummy-id';
testAction(
actions.removeConvertedDiscussion,
......@@ -781,7 +781,7 @@ describe('Actions Notes Store', () => {
};
});
it('when unresolved, dispatches action', done => {
it('when unresolved, dispatches action', (done) => {
testAction(
actions.resolveDiscussion,
{ discussionId },
......@@ -801,8 +801,8 @@ describe('Actions Notes Store', () => {
);
});
it('when resolved, does nothing', done => {
getters.isDiscussionResolved = id => id === discussionId;
it('when resolved, does nothing', (done) => {
getters.isDiscussionResolved = (id) => id === discussionId;
testAction(
actions.resolveDiscussion,
......@@ -823,7 +823,7 @@ describe('Actions Notes Store', () => {
const res = { errors: { something: ['went wrong'] } };
const error = { message: 'Unprocessable entity', response: { data: res } };
it('throws an error', done => {
it('throws an error', (done) => {
actions
.saveNote(
{
......@@ -833,7 +833,7 @@ describe('Actions Notes Store', () => {
payload,
)
.then(() => done.fail('Expected error to be thrown!'))
.catch(err => {
.catch((err) => {
expect(err).toBe(error);
expect(Flash).not.toHaveBeenCalled();
})
......@@ -846,7 +846,7 @@ describe('Actions Notes Store', () => {
const res = { errors: { base: ['something went wrong'] } };
const error = { message: 'Unprocessable entity', response: { data: res } };
it('sets flash alert using errors.base message', done => {
it('sets flash alert using errors.base message', (done) => {
actions
.saveNote(
{
......@@ -855,7 +855,7 @@ describe('Actions Notes Store', () => {
},
{ ...payload, flashContainer },
)
.then(resp => {
.then((resp) => {
expect(resp.hasFlash).toBe(true);
expect(Flash).toHaveBeenCalledWith(
'Your comment could not be submitted because something went wrong',
......@@ -872,7 +872,7 @@ describe('Actions Notes Store', () => {
describe('if response contains no errors', () => {
const res = { valid: true };
it('returns the response', done => {
it('returns the response', (done) => {
actions
.saveNote(
{
......@@ -881,7 +881,7 @@ describe('Actions Notes Store', () => {
},
payload,
)
.then(data => {
.then((data) => {
expect(data).toBe(res);
expect(Flash).not.toHaveBeenCalled();
})
......@@ -914,7 +914,7 @@ describe('Actions Notes Store', () => {
.catch(done.fail);
};
it('when service success, commits and resolves discussion', done => {
it('when service success, commits and resolves discussion', (done) => {
testSubmitSuggestion(done, () => {
expect(commit.mock.calls).toEqual([
[mutationTypes.SET_RESOLVING_DISCUSSION, true],
......@@ -931,7 +931,7 @@ describe('Actions Notes Store', () => {
});
});
it('when service fails, flashes error message', done => {
it('when service fails, flashes error message', (done) => {
const response = { response: { data: { message: TEST_ERROR_MESSAGE } } };
Api.applySuggestion.mockReturnValue(Promise.reject(response));
......@@ -946,7 +946,7 @@ describe('Actions Notes Store', () => {
});
});
it('when service fails, and no error message available, uses default message', done => {
it('when service fails, and no error message available, uses default message', (done) => {
const response = { response: 'foo' };
Api.applySuggestion.mockReturnValue(Promise.reject(response));
......@@ -965,7 +965,7 @@ describe('Actions Notes Store', () => {
});
});
it('when resolve discussion fails, fail gracefully', done => {
it('when resolve discussion fails, fail gracefully', (done) => {
dispatch.mockReturnValue(Promise.reject());
testSubmitSuggestion(done, () => {
......@@ -996,7 +996,7 @@ describe('Actions Notes Store', () => {
.catch(done.fail);
};
it('when service succeeds, commits, resolves discussions, resets batch and applying batch state', done => {
it('when service succeeds, commits, resolves discussions, resets batch and applying batch state', (done) => {
testSubmitSuggestionBatch(done, () => {
expect(commit.mock.calls).toEqual([
[mutationTypes.SET_APPLYING_BATCH_STATE, true],
......@@ -1019,7 +1019,7 @@ describe('Actions Notes Store', () => {
});
});
it('when service fails, flashes error message, resets applying batch state', done => {
it('when service fails, flashes error message, resets applying batch state', (done) => {
const response = { response: { data: { message: TEST_ERROR_MESSAGE } } };
Api.applySuggestionBatch.mockReturnValue(Promise.reject(response));
......@@ -1037,7 +1037,7 @@ describe('Actions Notes Store', () => {
});
});
it('when service fails, and no error message available, uses default message', done => {
it('when service fails, and no error message available, uses default message', (done) => {
const response = { response: 'foo' };
Api.applySuggestionBatch.mockReturnValue(Promise.reject(response));
......@@ -1059,7 +1059,7 @@ describe('Actions Notes Store', () => {
});
});
it('when resolve discussions fails, fails gracefully, resets batch and applying batch state', done => {
it('when resolve discussions fails, fails gracefully, resets batch and applying batch state', (done) => {
dispatch.mockReturnValue(Promise.reject());
testSubmitSuggestionBatch(done, () => {
......@@ -1081,7 +1081,7 @@ describe('Actions Notes Store', () => {
describe('addSuggestionInfoToBatch', () => {
const suggestionInfo = batchSuggestionsInfoMock[0];
it("adds a suggestion's info to the current batch", done => {
it("adds a suggestion's info to the current batch", (done) => {
testAction(
actions.addSuggestionInfoToBatch,
suggestionInfo,
......@@ -1096,7 +1096,7 @@ describe('Actions Notes Store', () => {
describe('removeSuggestionInfoFromBatch', () => {
const suggestionInfo = batchSuggestionsInfoMock[0];
it("removes a suggestion's info the current batch", done => {
it("removes a suggestion's info the current batch", (done) => {
testAction(
actions.removeSuggestionInfoFromBatch,
suggestionInfo.suggestionId,
......@@ -1136,7 +1136,7 @@ describe('Actions Notes Store', () => {
});
describe('setDiscussionSortDirection', () => {
it('calls the correct mutation with the correct args', done => {
it('calls the correct mutation with the correct args', (done) => {
testAction(
actions.setDiscussionSortDirection,
{ direction: notesConstants.DESC, persist: false },
......@@ -1154,7 +1154,7 @@ describe('Actions Notes Store', () => {
});
describe('setSelectedCommentPosition', () => {
it('calls the correct mutation with the correct args', done => {
it('calls the correct mutation with the correct args', (done) => {
testAction(
actions.setSelectedCommentPosition,
{},
......@@ -1175,7 +1175,7 @@ describe('Actions Notes Store', () => {
};
describe('if response contains no errors', () => {
it('dispatches requestDeleteDescriptionVersion', done => {
it('dispatches requestDeleteDescriptionVersion', (done) => {
axiosMock.onDelete(endpoint).replyOnce(200);
testAction(
actions.softDeleteDescriptionVersion,
......@@ -1198,7 +1198,7 @@ describe('Actions Notes Store', () => {
describe('if response contains errors', () => {
const errorMessage = 'Request failed with status code 503';
it('dispatches receiveDeleteDescriptionVersionError and throws an error', done => {
it('dispatches receiveDeleteDescriptionVersionError and throws an error', (done) => {
axiosMock.onDelete(endpoint).replyOnce(503);
testAction(
actions.softDeleteDescriptionVersion,
......@@ -1233,7 +1233,7 @@ describe('Actions Notes Store', () => {
});
describe('updateAssignees', () => {
it('update the assignees state', done => {
it('update the assignees state', (done) => {
testAction(
actions.updateAssignees,
[userDataMock.id],
......@@ -1348,7 +1348,7 @@ describe('Actions Notes Store', () => {
});
describe('updateDiscussionPosition', () => {
it('update the assignees state', done => {
it('update the assignees state', (done) => {
const updatedPosition = { discussionId: 1, position: { test: true } };
testAction(
actions.updateDiscussionPosition,
......
......@@ -72,7 +72,7 @@ describe('Getters Notes Store', () => {
state.isTimelineEnabled = true;
expect(getters.discussions(state).length).toEqual(discussionMock.notes.length);
getters.discussions(state).forEach(discussion => {
getters.discussions(state).forEach((discussion) => {
expect(discussion.individual_note).toBe(true);
expect(discussion.id).toBe(discussion.notes[0].id);
expect(discussion.created_at).toBe(discussion.notes[0].created_at);
......
......@@ -357,7 +357,7 @@ describe('Notes Store mutations', () => {
mutations.SET_EXPAND_DISCUSSIONS(state, { discussionIds, expanded: true });
state.discussions.forEach(discussion => {
state.discussions.forEach((discussion) => {
expect(discussion.expanded).toEqual(true);
});
});
......@@ -371,7 +371,7 @@ describe('Notes Store mutations', () => {
mutations.SET_EXPAND_DISCUSSIONS(state, { discussionIds, expanded: false });
state.discussions.forEach(discussion => {
state.discussions.forEach((discussion) => {
expect(discussion.expanded).toEqual(false);
});
});
......@@ -698,7 +698,7 @@ describe('Notes Store mutations', () => {
});
describe('SET_APPLYING_BATCH_STATE', () => {
const buildDiscussions = suggestionsInfo => {
const buildDiscussions = (suggestionsInfo) => {
const suggestions = suggestionsInfo.map(({ suggestionId }) => ({ id: suggestionId }));
const notes = suggestionsInfo.map(({ noteId }, index) => ({
......@@ -738,7 +738,7 @@ describe('Notes Store mutations', () => {
const expectedSuggestions = [updatedSuggestion, suggestions[1]];
const actualSuggestions = state.discussions
.map(discussion => discussion.notes.map(n => n.suggestions))
.map((discussion) => discussion.notes.map((n) => n.suggestions))
.flat(2);
expect(actualSuggestions).toEqual(expectedSuggestions);
......
......@@ -2,7 +2,7 @@ import $ from 'jquery';
import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
describe('OAuthRememberMe', () => {
const findFormAction = selector => {
const findFormAction = (selector) => {
return $(`#oauth-container .oauth-login${selector}`).parent('form').attr('action');
};
......
......@@ -11,7 +11,7 @@ describe('Package Additional Metadata', () => {
packageEntity: { ...mavenPackage },
};
const mountComponent = props => {
const mountComponent = (props) => {
wrapper = shallowMount(component, {
propsData: { ...defaultProps, ...props },
stubs: {
......@@ -33,7 +33,7 @@ describe('Package Additional Metadata', () => {
const findConanRecipe = () => wrapper.find('[data-testid="conan-recipe"]');
const findMavenApp = () => wrapper.find('[data-testid="maven-app"]');
const findMavenGroup = () => wrapper.find('[data-testid="maven-group"]');
const findElementLink = container => container.find(GlLink);
const findElementLink = (container) => container.find(GlLink);
it('has the correct title', () => {
mountComponent();
......
......@@ -15,10 +15,10 @@ describe('Package History', () => {
packageEntity: { ...mavenPackage },
};
const createPipelines = amount =>
const createPipelines = (amount) =>
[...Array(amount)].map((x, index) => ({ ...mockPipelineInfo, id: index + 1 }));
const mountComponent = props => {
const mountComponent = (props) => {
wrapper = shallowMount(component, {
propsData: { ...defaultProps, ...props },
stubs: {
......@@ -35,9 +35,9 @@ describe('Package History', () => {
wrapper = null;
});
const findHistoryElement = testId => wrapper.find(`[data-testid="${testId}"]`);
const findElementLink = container => container.find(GlLink);
const findElementTimeAgo = container => container.find(TimeAgoTooltip);
const findHistoryElement = (testId) => wrapper.find(`[data-testid="${testId}"]`);
const findElementLink = (container) => container.find(GlLink);
const findElementTimeAgo = (container) => container.find(TimeAgoTooltip);
const findTitle = () => wrapper.find('[data-testid="title"]');
const findTimeline = () => wrapper.find('[data-testid="timeline"]');
......
......@@ -12,7 +12,7 @@ jest.mock('~/api.js');
describe('Actions Package details store', () => {
describe('fetchPackageVersions', () => {
it('should fetch the package versions', done => {
it('should fetch the package versions', (done) => {
Api.projectPackage = jest.fn().mockResolvedValue({ data: packageEntity });
testAction(
......@@ -35,7 +35,7 @@ describe('Actions Package details store', () => {
);
});
it("does not set the versions if they don't exist", done => {
it("does not set the versions if they don't exist", (done) => {
Api.projectPackage = jest.fn().mockResolvedValue({ data: { packageEntity, versions: null } });
testAction(
......@@ -57,7 +57,7 @@ describe('Actions Package details store', () => {
);
});
it('should create flash on API error', done => {
it('should create flash on API error', (done) => {
Api.projectPackage = jest.fn().mockRejectedValue();
testAction(
......@@ -82,7 +82,7 @@ describe('Actions Package details store', () => {
});
describe('deletePackage', () => {
it('should call Api.deleteProjectPackage', done => {
it('should call Api.deleteProjectPackage', (done) => {
Api.deleteProjectPackage = jest.fn().mockResolvedValue();
testAction(deletePackage, undefined, { packageEntity }, [], [], () => {
expect(Api.deleteProjectPackage).toHaveBeenCalledWith(
......@@ -92,7 +92,7 @@ describe('Actions Package details store', () => {
done();
});
});
it('should create flash on API error', done => {
it('should create flash on API error', (done) => {
Api.deleteProjectPackage = jest.fn().mockRejectedValue();
testAction(deletePackage, undefined, { packageEntity }, [], [], () => {
......
......@@ -16,7 +16,7 @@ describe('packages_sort', () => {
const findPackageListSorting = () => wrapper.find(GlSorting);
const findSortingItems = () => wrapper.findAll(GlSortingItem);
const createStore = isGroupPage => {
const createStore = (isGroupPage) => {
const state = {
config: {
isGroupPage,
......
......@@ -30,7 +30,7 @@ describe('Actions Package list store', () => {
sort: 'asc',
orderBy: 'version',
};
it('should fetch the project packages list when isGroupPage is false', done => {
it('should fetch the project packages list when isGroupPage is false', (done) => {
testAction(
actions.requestPackagesList,
undefined,
......@@ -50,7 +50,7 @@ describe('Actions Package list store', () => {
);
});
it('should fetch the group packages list when isGroupPage is true', done => {
it('should fetch the group packages list when isGroupPage is true', (done) => {
testAction(
actions.requestPackagesList,
undefined,
......@@ -70,7 +70,7 @@ describe('Actions Package list store', () => {
);
});
it('should fetch packages of a certain type when selectedType is present', done => {
it('should fetch packages of a certain type when selectedType is present', (done) => {
const packageType = 'maven';
testAction(
......@@ -102,7 +102,7 @@ describe('Actions Package list store', () => {
);
});
it('should create flash on API error', done => {
it('should create flash on API error', (done) => {
Api.projectPackages = jest.fn().mockRejectedValue();
testAction(
actions.requestPackagesList,
......@@ -122,7 +122,7 @@ describe('Actions Package list store', () => {
});
describe('receivePackagesListSuccess', () => {
it('should set received packages', done => {
it('should set received packages', (done) => {
const data = 'foo';
testAction(
......@@ -140,7 +140,7 @@ describe('Actions Package list store', () => {
});
describe('setInitialState', () => {
it('should commit setInitialState', done => {
it('should commit setInitialState', (done) => {
testAction(
actions.setInitialState,
'1',
......@@ -153,7 +153,7 @@ describe('Actions Package list store', () => {
});
describe('setLoading', () => {
it('should commit set main loading', done => {
it('should commit set main loading', (done) => {
testAction(
actions.setLoading,
true,
......@@ -171,7 +171,7 @@ describe('Actions Package list store', () => {
delete_api_path: 'foo',
},
};
it('should perform a delete operation on _links.delete_api_path', done => {
it('should perform a delete operation on _links.delete_api_path', (done) => {
mock.onDelete(payload._links.delete_api_path).replyOnce(200);
Api.projectPackages = jest.fn().mockResolvedValue({ data: 'foo' });
......@@ -188,7 +188,7 @@ describe('Actions Package list store', () => {
);
});
it('should stop the loading and call create flash on api error', done => {
it('should stop the loading and call create flash on api error', (done) => {
mock.onDelete(payload._links.delete_api_path).replyOnce(400);
testAction(
actions.requestDeletePackage,
......@@ -211,7 +211,7 @@ describe('Actions Package list store', () => {
${'_links'} | ${{}}
${'delete_api_path'} | ${{ _links: {} }}
`('should reject and createFlash when $property is missing', ({ actionPayload }, done) => {
testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch(e => {
testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch((e) => {
expect(e).toEqual(new Error(MISSING_DELETE_PATH_ERROR));
expect(createFlash).toHaveBeenCalledWith(DELETE_PACKAGE_ERROR_MESSAGE);
done();
......@@ -220,7 +220,7 @@ describe('Actions Package list store', () => {
});
describe('setSorting', () => {
it('should commit SET_SORTING', done => {
it('should commit SET_SORTING', (done) => {
testAction(
actions.setSorting,
'foo',
......@@ -233,7 +233,7 @@ describe('Actions Package list store', () => {
});
describe('setFilter', () => {
it('should commit SET_FILTER', done => {
it('should commit SET_FILTER', (done) => {
testAction(
actions.setFilter,
'foo',
......
......@@ -21,8 +21,8 @@ describe('PackagePath', () => {
const ELLIPSIS_CHEVRON = 'ellipsis-chevron';
const LEAF_LINK = 'leaf-link';
const findItem = name => wrapper.find(`[data-testid="${name}"]`);
const findTooltip = w => getBinding(w.element, 'gl-tooltip');
const findItem = (name) => wrapper.find(`[data-testid="${name}"]`);
const findTooltip = (w) => getBinding(w.element, 'gl-tooltip');
afterEach(() => {
wrapper.destroy();
......@@ -64,13 +64,13 @@ describe('PackagePath', () => {
}
if (shouldExist.length) {
it.each(shouldExist)(`should have %s`, element => {
it.each(shouldExist)(`should have %s`, (element) => {
expect(findItem(element).exists()).toBe(true);
});
}
if (shouldNotExist.length) {
it.each(shouldNotExist)(`should not have %s`, element => {
it.each(shouldNotExist)(`should not have %s`, (element) => {
expect(findItem(element).exists()).toBe(false);
});
}
......
......@@ -13,7 +13,7 @@ describe('Packages shared utils', () => {
expect(packageTypeToTrackCategory()).toMatchInlineSnapshot(`"UI::undefined"`);
});
it.each(Object.keys(PackageType))('returns a correct category string for %s', packageKey => {
it.each(Object.keys(PackageType))('returns a correct category string for %s', (packageKey) => {
const packageName = PackageType[packageKey];
expect(packageTypeToTrackCategory(packageName)).toBe(
`UI::${TrackingCategories[packageName]}`,
......
......@@ -89,7 +89,7 @@ describe('pager', () => {
Pager.init();
});
it('shows loader while loading next page', done => {
it('shows loader while loading next page', (done) => {
mockSuccess();
jest.spyOn(Pager.loading, 'show').mockImplementation(() => {});
......@@ -102,7 +102,7 @@ describe('pager', () => {
});
});
it('hides loader on success', done => {
it('hides loader on success', (done) => {
mockSuccess();
jest.spyOn(Pager.loading, 'hide').mockImplementation(() => {});
......@@ -115,7 +115,7 @@ describe('pager', () => {
});
});
it('hides loader on error', done => {
it('hides loader on error', (done) => {
mockError();
jest.spyOn(Pager.loading, 'hide').mockImplementation(() => {});
......@@ -128,7 +128,7 @@ describe('pager', () => {
});
});
it('sends request to url with offset and limit params', done => {
it('sends request to url with offset and limit params', (done) => {
Pager.offset = 100;
Pager.limit = 20;
Pager.getOld();
......@@ -149,7 +149,7 @@ describe('pager', () => {
});
});
it('disables if return count is less than limit', done => {
it('disables if return count is less than limit', (done) => {
Pager.offset = 0;
Pager.limit = 20;
......
......@@ -8,10 +8,10 @@ describe('Abuse Reports', () => {
let $messages;
const assertMaxLength = $message => {
const assertMaxLength = ($message) => {
expect($message.text().length).toEqual(MAX_MESSAGE_LENGTH);
};
const findMessage = searchText =>
const findMessage = (searchText) =>
$messages.filter((index, element) => element.innerText.indexOf(searchText) > -1).first();
preloadFixtures(FIXTURE);
......
......@@ -24,7 +24,7 @@ describe('AccountAndLimits', () => {
expect($userInternalRegex.readOnly).toBeTruthy();
});
it('is checked', done => {
it('is checked', (done) => {
if (!$userDefaultExternal.prop('checked')) $userDefaultExternal.click();
expect($userDefaultExternal.prop('checked')).toBeTruthy();
......
......@@ -26,9 +26,9 @@ describe('stop_jobs_modal.vue', () => {
});
describe('onSubmit', () => {
it('stops jobs and redirects to overview page', done => {
it('stops jobs and redirects to overview page', (done) => {
const responseURL = `${TEST_HOST}/stop_jobs_modal.vue/jobs`;
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(props.url);
return Promise.resolve({
request: {
......@@ -45,16 +45,16 @@ describe('stop_jobs_modal.vue', () => {
.catch(done.fail);
});
it('displays error if stopping jobs failed', done => {
it('displays error if stopping jobs failed', (done) => {
const dummyError = new Error('stopping jobs failed');
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(props.url);
return Promise.reject(dummyError);
});
vm.onSubmit()
.then(done.fail)
.catch(error => {
.catch((error) => {
expect(error).toBe(dummyError);
expect(redirectTo).not.toHaveBeenCalled();
})
......
......@@ -11,10 +11,10 @@ describe('User Operation confirmation modal', () => {
let wrapper;
let formSubmitSpy;
const findButton = variant =>
const findButton = (variant) =>
wrapper
.findAll(GlButton)
.filter(w => w.attributes('variant') === variant)
.filter((w) => w.attributes('variant') === variant)
.at(0);
const findForm = () => wrapper.find('form');
const findUsernameInput = () => wrapper.find(GlFormInput);
......@@ -25,7 +25,7 @@ describe('User Operation confirmation modal', () => {
const getMethodParam = () => new FormData(findForm().element).get('_method');
const getFormAction = () => findForm().attributes('action');
const setUsername = username => {
const setUsername = (username) => {
findUsernameInput().vm.$emit('input', username);
};
......
......@@ -20,7 +20,7 @@ describe('UserInternalRegexHandler', () => {
});
describe('Behaviour of userExternal checkbox when', () => {
it('matches email as internal', done => {
it('matches email as internal', (done) => {
expect($warningMessage.hasClass('hidden')).toBeTruthy();
$userEmail.val('test@').trigger('input');
......@@ -30,7 +30,7 @@ describe('UserInternalRegexHandler', () => {
done();
});
it('matches email as external', done => {
it('matches email as external', (done) => {
expect($warningMessage.hasClass('hidden')).toBeTruthy();
$userEmail.val('test.ext@').trigger('input');
......
......@@ -31,10 +31,10 @@ describe('Todos', () => {
});
describe('goToTodoUrl', () => {
it('opens the todo url', done => {
it('opens the todo url', (done) => {
const todoLink = todoItem.dataset.url;
visitUrl.mockImplementation(url => {
visitUrl.mockImplementation((url) => {
expect(url).toEqual(todoLink);
done();
});
......@@ -61,7 +61,7 @@ describe('Todos', () => {
});
it('run native funcionality when avatar is clicked', () => {
$('.todos-list a').on('click', e => e.preventDefault());
$('.todos-list a').on('click', (e) => e.preventDefault());
$('.todos-list img').trigger(metakeyEvent);
expect(visitUrl).not.toHaveBeenCalled();
......@@ -72,7 +72,7 @@ describe('Todos', () => {
describe('on done todo click', () => {
let onToggleSpy;
beforeEach(done => {
beforeEach((done) => {
const el = document.querySelector('.js-done-todo');
const path = el.dataset.href;
......
......@@ -15,7 +15,7 @@ describe('BitbucketServerStatusTable', () => {
const findReconfigureButton = () =>
wrapper
.findAll(GlButton)
.filter(w => w.props().variant === 'info')
.filter((w) => w.props().variant === 'info')
.at(0);
afterEach(() => {
......
......@@ -50,9 +50,9 @@ describe('Promote label modal', () => {
vm.$destroy();
});
it('redirects when a label is promoted', done => {
it('redirects when a label is promoted', (done) => {
const responseURL = `${TEST_HOST}/dummy/endpoint`;
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(labelMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
'promoteLabelModal.requestStarted',
......@@ -76,10 +76,10 @@ describe('Promote label modal', () => {
.catch(done.fail);
});
it('displays an error if promoting a label failed', done => {
it('displays an error if promoting a label failed', (done) => {
const dummyError = new Error('promoting label failed');
dummyError.response = { status: 500 };
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(labelMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
'promoteLabelModal.requestStarted',
......@@ -89,7 +89,7 @@ describe('Promote label modal', () => {
});
vm.onSubmit()
.catch(error => {
.catch((error) => {
expect(error).toBe(dummyError);
expect(eventHub.$emit).toHaveBeenCalledWith('promoteLabelModal.requestFinished', {
labelUrl: labelMockData.url,
......
......@@ -32,9 +32,9 @@ describe('delete_milestone_modal.vue', () => {
jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
});
it('deletes milestone and redirects to overview page', done => {
it('deletes milestone and redirects to overview page', (done) => {
const responseURL = `${TEST_HOST}/delete_milestone_modal.vue/milestoneOverview`;
jest.spyOn(axios, 'delete').mockImplementation(url => {
jest.spyOn(axios, 'delete').mockImplementation((url) => {
expect(url).toBe(props.milestoneUrl);
expect(eventHub.$emit).toHaveBeenCalledWith(
'deleteMilestoneModal.requestStarted',
......@@ -60,10 +60,10 @@ describe('delete_milestone_modal.vue', () => {
.catch(done.fail);
});
it('displays error if deleting milestone failed', done => {
it('displays error if deleting milestone failed', (done) => {
const dummyError = new Error('deleting milestone failed');
dummyError.response = { status: 418 };
jest.spyOn(axios, 'delete').mockImplementation(url => {
jest.spyOn(axios, 'delete').mockImplementation((url) => {
expect(url).toBe(props.milestoneUrl);
expect(eventHub.$emit).toHaveBeenCalledWith(
'deleteMilestoneModal.requestStarted',
......@@ -74,7 +74,7 @@ describe('delete_milestone_modal.vue', () => {
});
vm.onSubmit()
.catch(error => {
.catch((error) => {
expect(error).toBe(dummyError);
expect(redirectTo).not.toHaveBeenCalled();
expect(eventHub.$emit).toHaveBeenCalledWith('deleteMilestoneModal.requestFinished', {
......
......@@ -46,9 +46,9 @@ describe('Promote milestone modal', () => {
vm.$destroy();
});
it('redirects when a milestone is promoted', done => {
it('redirects when a milestone is promoted', (done) => {
const responseURL = `${TEST_HOST}/dummy/endpoint`;
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(milestoneMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
'promoteMilestoneModal.requestStarted',
......@@ -72,10 +72,10 @@ describe('Promote milestone modal', () => {
.catch(done.fail);
});
it('displays an error if promoting a milestone failed', done => {
it('displays an error if promoting a milestone failed', (done) => {
const dummyError = new Error('promoting milestone failed');
dummyError.response = { status: 500 };
jest.spyOn(axios, 'post').mockImplementation(url => {
jest.spyOn(axios, 'post').mockImplementation((url) => {
expect(url).toBe(milestoneMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
'promoteMilestoneModal.requestStarted',
......@@ -85,7 +85,7 @@ describe('Promote milestone modal', () => {
});
vm.onSubmit()
.catch(error => {
.catch((error) => {
expect(error).toBe(dummyError);
expect(eventHub.$emit).toHaveBeenCalledWith('promoteMilestoneModal.requestFinished', {
milestoneUrl: milestoneMockData.url,
......
......@@ -46,7 +46,7 @@ describe('EmojiMenu', () => {
const dummyEmoji = 'tropical_fish';
const dummyVotesBlock = () => $('<div />');
it('calls selectEmojiCallback', done => {
it('calls selectEmojiCallback', (done) => {
expect(dummySelectEmojiCallback).not.toHaveBeenCalled();
emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => {
......@@ -55,7 +55,7 @@ describe('EmojiMenu', () => {
});
});
it('does not make an axios request', done => {
it('does not make an axios request', (done) => {
jest.spyOn(axios, 'request').mockReturnValue();
emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => {
......
......@@ -30,7 +30,7 @@ describe('Fork groups list item component', () => {
const DUMMY_PATH = '/dummy/path';
const createWrapper = propsData => {
const createWrapper = (propsData) => {
wrapper = shallowMount(ForkGroupsListItem, {
propsData: {
...DEFAULT_PROPS,
......@@ -70,7 +70,7 @@ describe('Fork groups list item component', () => {
expect(
wrapper
.findAll(GlLink)
.filter(w => w.text() === DUMMY_FULL_NAME)
.filter((w) => w.text() === DUMMY_FULL_NAME)
.at(0)
.attributes().href,
).toBe(DUMMY_PATH);
......
......@@ -21,7 +21,7 @@ describe('Fork groups list component', () => {
const replyWith = (...args) => axiosMock.onGet(DEFAULT_PROPS.endpoint).reply(...args);
const createWrapper = propsData => {
const createWrapper = (propsData) => {
wrapper = shallowMount(ForkGroupsList, {
propsData: {
...DEFAULT_PROPS,
......
......@@ -26,7 +26,7 @@ describe('Interval Pattern Input Component', () => {
const findCustomInput = () => wrapper.find('#schedule_cron');
const findAllLabels = () => wrapper.findAll('label');
const findSelectedRadio = () =>
wrapper.findAll('input[type="radio"]').wrappers.find(x => x.element.checked);
wrapper.findAll('input[type="radio"]').wrappers.find((x) => x.element.checked);
const findSelectedRadioKey = () => findSelectedRadio()?.attributes('data-testid');
const selectEveryDayRadio = () => findEveryDayRadio().trigger('click');
const selectEveryWeekRadio = () => findEveryWeekRadio().trigger('click');
......@@ -129,7 +129,7 @@ describe('Interval Pattern Input Component', () => {
});
it('renders each label for radio options properly', () => {
const labels = findAllLabels().wrappers.map(el => trimText(el.text()));
const labels = findAllLabels().wrappers.map((el) => trimText(el.text()));
expect(labels).toEqual([
'Every day (at 4:00am)',
......
......@@ -47,7 +47,7 @@ describe('Timezone Dropdown', () => {
const data = $dropdownEl.data('data');
const formatted = $wrapper.find(tzListSel).text();
data.forEach(item => {
data.forEach((item) => {
expect(formatted).toContain(formatTimezone(item));
});
});
......@@ -100,7 +100,7 @@ describe('Timezone Dropdown', () => {
new TimezoneDropdown({
$inputEl,
$dropdownEl,
displayFormat: selectedItem => formatTimezone(selectedItem),
displayFormat: (selectedItem) => formatTimezone(selectedItem),
});
expect($wrapper.find(tzDropdownToggleText).html()).toEqual('[UTC - 2.5] Newfoundland');
......
......@@ -19,7 +19,7 @@ describe('Project Feature Settings', () => {
};
let wrapper;
const mountComponent = customProps => {
const mountComponent = (customProps) => {
const propsData = { ...defaultProps, ...customProps };
return shallowMount(projectFeatureSetting, { propsData });
};
......
......@@ -367,7 +367,7 @@ describe('Settings Panel', () => {
const repositoryFeatureToggleButton = findRepositoryFeatureSetting().find('button');
const lfsFeatureToggleButton = findLFSFeatureToggle().find('button');
const isToggleButtonChecked = toggleButton => toggleButton.classes('is-checked');
const isToggleButtonChecked = (toggleButton) => toggleButton.classes('is-checked');
// assert the initial state
expect(isToggleButtonChecked(lfsFeatureToggleButton)).toBe(true);
......
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