Commit 5c23cb94 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 44 files - 62 of 73

Part of our prettier migration; changing the arrow-parens style.
parent c35cc92c
......@@ -1887,52 +1887,6 @@ spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_using_real_timer.js
## practical-murdock
spec/frontend/issuable_spec.js
spec/frontend/issue_show/components/app_spec.js
spec/frontend/issue_show/components/description_spec.js
spec/frontend/issue_show/components/edit_actions_spec.js
spec/frontend/issue_show/components/fields/description_spec.js
spec/frontend/issue_show/components/form_spec.js
spec/frontend/issue_show/components/header_actions_spec.js
spec/frontend/issue_show/components/incidents/highlight_bar_spec.js
spec/frontend/issue_show/components/pinned_links_spec.js
spec/frontend/issue_show/issue_spec.js
spec/frontend/issue_spec.js
spec/frontend/issues_list/components/issuable_spec.js
spec/frontend/issues_list/components/issuables_list_app_spec.js
spec/frontend/jira_import/components/jira_import_form_spec.js
spec/frontend/jira_import/components/jira_import_progress_spec.js
spec/frontend/jira_import/components/jira_import_setup_spec.js
spec/frontend/jobs/components/artifacts_block_spec.js
spec/frontend/jobs/components/empty_state_spec.js
spec/frontend/jobs/components/erased_block_spec.js
spec/frontend/jobs/components/job_app_spec.js
spec/frontend/jobs/components/job_container_item_spec.js
spec/frontend/jobs/components/job_log_controllers_spec.js
spec/frontend/jobs/components/log/line_spec.js
spec/frontend/jobs/components/manual_variables_form_spec.js
spec/frontend/jobs/components/stuck_block_spec.js
spec/frontend/jobs/components/trigger_block_spec.js
spec/frontend/jobs/store/actions_spec.js
spec/frontend/jobs/store/helpers.js
spec/frontend/lazy_loader_spec.js
spec/frontend/lib/dompurify_spec.js
spec/frontend/lib/utils/ajax_cache_spec.js
spec/frontend/lib/utils/apollo_startup_js_link_spec.js
spec/frontend/lib/utils/common_utils_spec.js
spec/frontend/lib/utils/datetime_range_spec.js
spec/frontend/lib/utils/datetime_utility_spec.js
spec/frontend/lib/utils/dom_utils_spec.js
spec/frontend/lib/utils/forms_spec.js
spec/frontend/lib/utils/highlight_spec.js
spec/frontend/lib/utils/icon_utils_spec.js
spec/frontend/lib/utils/poll_spec.js
spec/frontend/lib/utils/poll_until_complete_spec.js
spec/frontend/lib/utils/text_utility_spec.js
spec/frontend/lib/utils/url_utility_spec.js
spec/frontend/lib/utils/users_cache_spec.js
## determined-shamir
spec/frontend/logs/components/environment_logs_spec.js
spec/frontend/logs/components/log_advanced_filters_spec.js
......
......@@ -49,7 +49,7 @@ describe('Issuable', () => {
mock.restore();
});
it('should send request to reset email token', done => {
it('should send request to reset email token', (done) => {
jest.spyOn(axios, 'put');
document.querySelector('.incoming-email-token-reset').click();
......
......@@ -398,8 +398,8 @@ describe('Issuable output', () => {
wrapper.vm.poll.makeRequest();
return new Promise(resolve => {
wrapper.vm.$watch('formState.lockedWarningVisible', value => {
return new Promise((resolve) => {
wrapper.vm.$watch('formState.lockedWarningVisible', (value) => {
if (value) {
resolve();
}
......
......@@ -74,7 +74,7 @@ describe('Description component', () => {
let modal;
const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle
child => child.$options._componentTag === 'recaptcha-modal',
(child) => child.$options._componentTag === 'recaptcha-modal',
);
recaptchaChild.scriptSrc = '//scriptsrc';
......
......@@ -6,7 +6,7 @@ import Store from '~/issue_show/stores';
describe('Edit Actions components', () => {
let vm;
beforeEach(done => {
beforeEach((done) => {
const Component = Vue.extend(editActions);
const store = new Store({
titleHtml: '',
......@@ -34,7 +34,7 @@ describe('Edit Actions components', () => {
expect(vm.$el.querySelectorAll('[disabled]').length).toBe(0);
});
it('does not render delete button if canUpdate is false', done => {
it('does not render delete button if canUpdate is false', (done) => {
vm.canDestroy = false;
Vue.nextTick(() => {
......@@ -44,7 +44,7 @@ describe('Edit Actions components', () => {
});
});
it('disables submit button when title is blank', done => {
it('disables submit button when title is blank', (done) => {
vm.formState.title = '';
Vue.nextTick(() => {
......@@ -54,7 +54,7 @@ describe('Edit Actions components', () => {
});
});
it('should not show delete button if showDeleteButton is false', done => {
it('should not show delete button if showDeleteButton is false', (done) => {
vm.showDeleteButton = false;
Vue.nextTick(() => {
......@@ -70,7 +70,7 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
});
it('disabled button after clicking save button', done => {
it('disabled button after clicking save button', (done) => {
vm.$el.querySelector('.btn-success').click();
Vue.nextTick(() => {
......@@ -97,7 +97,7 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('delete.issuable', { destroy_confirm: true });
});
it('does no actions when confirm is false', done => {
it('does no actions when confirm is false', (done) => {
jest.spyOn(window, 'confirm').mockReturnValue(false);
vm.$el.querySelector('.btn-danger').click();
......
......@@ -8,7 +8,7 @@ describe('Description field component', () => {
let vm;
let store;
beforeEach(done => {
beforeEach((done) => {
const Component = Vue.extend(descriptionField);
const el = document.createElement('div');
store = new Store({
......@@ -38,7 +38,7 @@ describe('Description field component', () => {
expect(vm.$el.querySelector('.md-area textarea').value).toBe('test');
});
it('renders markdown field with a markdown description', done => {
it('renders markdown field with a markdown description', (done) => {
store.formState.description = '**test**';
Vue.nextTick(() => {
......
......@@ -26,7 +26,7 @@ describe('Inline edit form component', () => {
vm.$destroy();
});
const createComponent = props => {
const createComponent = (props) => {
const Component = Vue.extend(formComponent);
vm = mountComponent(Component, {
......
......@@ -62,7 +62,7 @@ describe('HeaderActions component', () => {
const findToggleIssueStateButton = () => wrapper.find(GlButton);
const findDropdownAt = index => wrapper.findAll(GlDropdown).at(index);
const findDropdownAt = (index) => wrapper.findAll(GlDropdown).at(index);
const findMobileDropdownItems = () => findDropdownAt(0).findAll(GlDropdownItem);
......@@ -70,7 +70,7 @@ describe('HeaderActions component', () => {
const findModal = () => wrapper.find(GlModal);
const findModalLinkAt = index => findModal().findAll(GlLink).at(index);
const findModalLinkAt = (index) => findModal().findAll(GlLink).at(index);
const mountComponent = ({
props = {},
......@@ -205,7 +205,7 @@ describe('HeaderActions component', () => {
it(`${isItemVisible ? 'shows' : 'hides'} "${itemText}" item`, () => {
expect(
findDropdownItems()
.filter(item => item.text() === itemText)
.filter((item) => item.text() === itemText)
.exists(),
).toBe(isItemVisible);
});
......
......@@ -17,7 +17,7 @@ describe('Highlight Bar', () => {
title: 'Alert 1',
};
const mountComponent = options => {
const mountComponent = (options) => {
wrapper = shallowMount(
HighlightBar,
merge(
......
......@@ -11,7 +11,7 @@ describe('PinnedLinks', () => {
const findButtons = () => wrapper.findAll(GlButton);
const createComponent = props => {
const createComponent = (props) => {
wrapper = shallowMount(PinnedLinks, {
propsData: {
zoomMeetingUrl: '',
......
......@@ -14,7 +14,7 @@ useMockIntersectionObserver();
jest.mock('~/lib/utils/poll');
const setupHTML = initialData => {
const setupHTML = (initialData) => {
document.body.innerHTML = `<div id="js-issuable-app"></div>`;
document.getElementById('js-issuable-app').dataset.initial = JSON.stringify(initialData);
};
......
......@@ -41,7 +41,7 @@ describe('Issue', () => {
expect($boxOpen).toHaveText('Open');
}
[true, false].forEach(isIssueInitiallyOpen => {
[true, false].forEach((isIssueInitiallyOpen) => {
describe(`with ${isIssueInitiallyOpen ? 'open' : 'closed'} issue`, () => {
const action = isIssueInitiallyOpen ? 'close' : 'reopen';
let mock;
......
......@@ -72,9 +72,9 @@ describe('Issuable component', () => {
window.Date = DateOrig;
});
const checkExists = findFn => () => findFn().exists();
const checkExists = (findFn) => () => findFn().exists();
const hasIcon = (iconName, iconWrapper = wrapper) =>
iconWrapper.findAll(GlIcon).wrappers.some(icon => icon.props('name') === iconName);
iconWrapper.findAll(GlIcon).wrappers.some((icon) => icon.props('name') === iconName);
const hasConfidentialIcon = () => hasIcon('eye-slash');
const findTaskStatus = () => wrapper.find('.task-status');
const findOpenedAgoContainer = () => wrapper.find('[data-testid="openedByMessage"]');
......@@ -91,8 +91,8 @@ describe('Issuable component', () => {
const findDownvotes = () => wrapper.find('[data-testid="downvotes"]');
const findNotes = () => wrapper.find('[data-testid="notes-count"]');
const findBulkCheckbox = () => wrapper.find('input.selected-issuable');
const findScopedLabels = () => findLabels().filter(w => isScopedLabel({ title: w.text() }));
const findUnscopedLabels = () => findLabels().filter(w => !isScopedLabel({ title: w.text() }));
const findScopedLabels = () => findLabels().filter((w) => isScopedLabel({ title: w.text() }));
const findUnscopedLabels = () => findLabels().filter((w) => !isScopedLabel({ title: w.text() }));
const findIssuableTitle = () => wrapper.find('[data-testid="issuable-title"]');
const findIssuableStatus = () => wrapper.find('[data-testid="issuable-status"]');
const containsJiraLogo = () => wrapper.find('[data-testid="jira-logo"]').exists();
......@@ -336,13 +336,13 @@ describe('Issuable component', () => {
it('renders labels', () => {
factory({ issuable });
const labels = findLabels().wrappers.map(label => ({
const labels = findLabels().wrappers.map((label) => ({
href: label.props('target'),
text: label.text(),
tooltip: label.attributes('description'),
}));
const expected = testLabels.map(label => ({
const expected = testLabels.map((label) => ({
href: mergeUrlParams({ 'label_name[]': label.name }, TEST_BASE_URL),
text: label.name,
tooltip: label.description,
......@@ -363,13 +363,13 @@ describe('Issuable component', () => {
it('renders labels', () => {
factory({ issuable });
const labels = findLabels().wrappers.map(label => ({
const labels = findLabels().wrappers.map((label) => ({
href: label.props('target'),
text: label.text(),
tooltip: label.attributes('description'),
}));
const expected = testLabels.map(label => ({
const expected = testLabels.map((label) => ({
href: mergeUrlParams({ 'labels[]': label.name }, TEST_BASE_URL),
text: label.name,
tooltip: label.description,
......
......@@ -27,7 +27,7 @@ const TEST_ENDPOINT = '/issues';
const TEST_CREATE_ISSUES_PATH = '/createIssue';
const TEST_SVG_PATH = '/emptySvg';
const setUrl = query => {
const setUrl = (query) => {
window.location.href = `${TEST_LOCATION}${query}`;
window.location.search = query;
};
......@@ -45,10 +45,10 @@ describe('Issuables list component', () => {
let wrapper;
let apiSpy;
const setupApiMock = cb => {
const setupApiMock = (cb) => {
apiSpy = jest.fn(cb);
mockAxios.onGet(TEST_ENDPOINT).reply(cfg => apiSpy(cfg));
mockAxios.onGet(TEST_ENDPOINT).reply((cfg) => apiSpy(cfg));
};
const factory = (props = { sortKey: 'priority' }) => {
......
......@@ -37,7 +37,7 @@ describe('JiraImportForm', () => {
const getUserDropdown = () => getTable().find(GlDropdown);
const getHeader = name => getByRole(wrapper.element, 'columnheader', { name });
const getHeader = (name) => getByRole(wrapper.element, 'columnheader', { name });
const findLoadMoreUsersButton = () => wrapper.find('[data-testid="load-more-users-button"]');
......
......@@ -8,7 +8,7 @@ describe('JiraImportProgress', () => {
const importProject = 'JIRAPROJECT';
const getGlEmptyStateProp = attribute => wrapper.find(GlEmptyState).props(attribute);
const getGlEmptyStateProp = (attribute) => wrapper.find(GlEmptyState).props(attribute);
const getParagraphText = () => wrapper.find('p').text();
......
......@@ -6,7 +6,7 @@ import { illustration, jiraIntegrationPath } from '../mock_data';
describe('JiraImportSetup', () => {
let wrapper;
const getGlEmptyStateProp = attribute => wrapper.find(GlEmptyState).props(attribute);
const getGlEmptyStateProp = (attribute) => wrapper.find(GlEmptyState).props(attribute);
beforeEach(() => {
wrapper = shallowMount(JiraImportSetup, {
......
......@@ -6,7 +6,7 @@ import { trimText } from '../../helpers/text_helper';
describe('Artifacts block', () => {
let wrapper;
const createWrapper = propsData =>
const createWrapper = (propsData) =>
mount(ArtifactsBlock, {
propsData: {
helpUrl: 'help-url',
......
......@@ -12,7 +12,7 @@ describe('Empty State', () => {
variablesSettingsUrl: '',
};
const createWrapper = props => {
const createWrapper = (props) => {
wrapper = mount(EmptyState, {
propsData: {
...defaultProps,
......
......@@ -10,7 +10,7 @@ describe('Erased block', () => {
const timeago = getTimeago();
const formattedDate = timeago.format(erasedAt);
const createComponent = props => {
const createComponent = (props) => {
wrapper = mount(ErasedBlock, {
propsData: props,
});
......
......@@ -375,7 +375,7 @@ describe('Job App', () => {
});
describe('sidebar', () => {
it('has no blank blocks', done => {
it('has no blank blocks', (done) => {
setupAndMount({
jobData: {
duration: null,
......@@ -392,7 +392,7 @@ describe('Job App', () => {
const blocks = wrapper.findAll('.blocks-container > *').wrappers;
expect(blocks.length).toBeGreaterThan(0);
blocks.forEach(block => {
blocks.forEach((block) => {
expect(block.text().trim()).not.toBe('');
});
})
......
......@@ -82,7 +82,7 @@ describe('JobContainerItem', () => {
);
});
it('displays remaining time in tooltip', done => {
it('displays remaining time in tooltip', (done) => {
vm = mountComponent(Component, {
job: delayedJobFixture,
isActive: false,
......
......@@ -21,7 +21,7 @@ describe('Job log controllers', () => {
isTraceSizeVisible: true,
};
const createWrapper = props => {
const createWrapper = (props) => {
wrapper = mount(JobLogControllers, {
propsData: {
...defaultProps,
......
......@@ -34,7 +34,7 @@ describe('Job Log Line', () => {
const findLine = () => wrapper.find('span');
const findLink = () => findLine().find('a');
const findLinks = () => findLine().findAll('a');
const findLinkAttributeByIndex = i => findLinks().at(i).attributes();
const findLinkAttributeByIndex = (i) => findLinks().at(i).attributes();
beforeEach(() => {
data = mockProps();
......
......@@ -27,7 +27,7 @@ describe('Manual Variables Form', () => {
factory(requiredProps);
});
afterEach(done => {
afterEach((done) => {
// The component has a `nextTick` callback after some events so we need
// to wait for those to finish before destroying.
setImmediate(() => {
......@@ -54,7 +54,7 @@ describe('Manual Variables Form', () => {
});
describe('when adding a new variable', () => {
it('creates a new variable when user types a new key and resets the form', done => {
it('creates a new variable when user types a new key and resets the form', (done) => {
wrapper.vm
.$nextTick()
.then(() => wrapper.find({ ref: 'inputKey' }).setValue('new key'))
......@@ -67,7 +67,7 @@ describe('Manual Variables Form', () => {
.catch(done.fail);
});
it('creates a new variable when user types a new value and resets the form', done => {
it('creates a new variable when user types a new value and resets the form', (done) => {
wrapper.vm
.$nextTick()
.then(() => wrapper.find({ ref: 'inputSecretValue' }).setValue('new value'))
......@@ -82,7 +82,7 @@ describe('Manual Variables Form', () => {
});
describe('when deleting a variable', () => {
beforeEach(done => {
beforeEach((done) => {
wrapper.vm.variables = [
{
key: 'new key',
......
......@@ -12,7 +12,7 @@ describe('Stuck Block Job component', () => {
}
});
const createWrapper = props => {
const createWrapper = (props) => {
wrapper = shallowMount(StuckBlock, {
propsData: {
...props,
......
......@@ -32,7 +32,7 @@ describe('Trigger block', () => {
describe('with variables', () => {
describe('hide/reveal variables', () => {
it('should toggle variables on click', done => {
it('should toggle variables on click', (done) => {
vm = mountComponent(Component, {
trigger: {
short_token: 'bd7e',
......
......@@ -40,7 +40,7 @@ describe('Job State actions', () => {
});
describe('setJobEndpoint', () => {
it('should commit SET_JOB_ENDPOINT mutation', done => {
it('should commit SET_JOB_ENDPOINT mutation', (done) => {
testAction(
setJobEndpoint,
'job/872324.json',
......@@ -53,7 +53,7 @@ describe('Job State actions', () => {
});
describe('setTraceOptions', () => {
it('should commit SET_TRACE_OPTIONS mutation', done => {
it('should commit SET_TRACE_OPTIONS mutation', (done) => {
testAction(
setTraceOptions,
{ pagePath: 'job/872324/trace.json' },
......@@ -66,26 +66,26 @@ describe('Job State actions', () => {
});
describe('hideSidebar', () => {
it('should commit HIDE_SIDEBAR mutation', done => {
it('should commit HIDE_SIDEBAR mutation', (done) => {
testAction(hideSidebar, null, mockedState, [{ type: types.HIDE_SIDEBAR }], [], done);
});
});
describe('showSidebar', () => {
it('should commit HIDE_SIDEBAR mutation', done => {
it('should commit HIDE_SIDEBAR mutation', (done) => {
testAction(showSidebar, null, mockedState, [{ type: types.SHOW_SIDEBAR }], [], done);
});
});
describe('toggleSidebar', () => {
describe('when isSidebarOpen is true', () => {
it('should dispatch hideSidebar', done => {
it('should dispatch hideSidebar', (done) => {
testAction(toggleSidebar, null, mockedState, [], [{ type: 'hideSidebar' }], done);
});
});
describe('when isSidebarOpen is false', () => {
it('should dispatch showSidebar', done => {
it('should dispatch showSidebar', (done) => {
mockedState.isSidebarOpen = false;
testAction(toggleSidebar, null, mockedState, [], [{ type: 'showSidebar' }], done);
......@@ -94,7 +94,7 @@ describe('Job State actions', () => {
});
describe('requestJob', () => {
it('should commit REQUEST_JOB mutation', done => {
it('should commit REQUEST_JOB mutation', (done) => {
testAction(requestJob, null, mockedState, [{ type: types.REQUEST_JOB }], [], done);
});
});
......@@ -114,7 +114,7 @@ describe('Job State actions', () => {
});
describe('success', () => {
it('dispatches requestJob and receiveJobSuccess ', done => {
it('dispatches requestJob and receiveJobSuccess ', (done) => {
mock.onGet(`${TEST_HOST}/endpoint.json`).replyOnce(200, { id: 121212, name: 'karma' });
testAction(
......@@ -141,7 +141,7 @@ describe('Job State actions', () => {
mock.onGet(`${TEST_HOST}/endpoint.json`).reply(500);
});
it('dispatches requestJob and receiveJobError ', done => {
it('dispatches requestJob and receiveJobError ', (done) => {
testAction(
fetchJob,
null,
......@@ -160,7 +160,7 @@ describe('Job State actions', () => {
});
});
it('fetchTrace is called only if the job has started or has a trace', done => {
it('fetchTrace is called only if the job has started or has a trace', (done) => {
mock.onGet(`${TEST_HOST}/endpoint.json`).replyOnce(200, { id: 121212, name: 'karma' });
mockedState.job.started = true;
......@@ -188,7 +188,7 @@ describe('Job State actions', () => {
});
describe('receiveJobSuccess', () => {
it('should commit RECEIVE_JOB_SUCCESS mutation', done => {
it('should commit RECEIVE_JOB_SUCCESS mutation', (done) => {
testAction(
receiveJobSuccess,
{ id: 121232132 },
......@@ -201,25 +201,25 @@ describe('Job State actions', () => {
});
describe('receiveJobError', () => {
it('should commit RECEIVE_JOB_ERROR mutation', done => {
it('should commit RECEIVE_JOB_ERROR mutation', (done) => {
testAction(receiveJobError, null, mockedState, [{ type: types.RECEIVE_JOB_ERROR }], [], done);
});
});
describe('scrollTop', () => {
it('should dispatch toggleScrollButtons action', done => {
it('should dispatch toggleScrollButtons action', (done) => {
testAction(scrollTop, null, mockedState, [], [{ type: 'toggleScrollButtons' }], done);
});
});
describe('scrollBottom', () => {
it('should dispatch toggleScrollButtons action', done => {
it('should dispatch toggleScrollButtons action', (done) => {
testAction(scrollBottom, null, mockedState, [], [{ type: 'toggleScrollButtons' }], done);
});
});
describe('requestTrace', () => {
it('should commit REQUEST_TRACE mutation', done => {
it('should commit REQUEST_TRACE mutation', (done) => {
testAction(requestTrace, null, mockedState, [{ type: types.REQUEST_TRACE }], [], done);
});
});
......@@ -239,7 +239,7 @@ describe('Job State actions', () => {
});
describe('success', () => {
it('dispatches requestTrace, receiveTraceSuccess and stopPollingTrace when job is complete', done => {
it('dispatches requestTrace, receiveTraceSuccess and stopPollingTrace when job is complete', (done) => {
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, {
html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
complete: true,
......@@ -282,7 +282,7 @@ describe('Job State actions', () => {
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, tracePayload);
});
it('dispatches startPollingTrace', done => {
it('dispatches startPollingTrace', (done) => {
testAction(
fetchTrace,
null,
......@@ -297,7 +297,7 @@ describe('Job State actions', () => {
);
});
it('does not dispatch startPollingTrace when timeout is non-empty', done => {
it('does not dispatch startPollingTrace when timeout is non-empty', (done) => {
mockedState.traceTimeout = 1;
testAction(
......@@ -320,7 +320,7 @@ describe('Job State actions', () => {
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).reply(500);
});
it('dispatches requestTrace and receiveTraceError ', done => {
it('dispatches requestTrace and receiveTraceError ', (done) => {
testAction(
fetchTrace,
null,
......@@ -385,7 +385,7 @@ describe('Job State actions', () => {
window.clearTimeout = origTimeout;
});
it('should commit STOP_POLLING_TRACE mutation ', done => {
it('should commit STOP_POLLING_TRACE mutation ', (done) => {
const traceTimeout = 7;
testAction(
......@@ -404,7 +404,7 @@ describe('Job State actions', () => {
});
describe('receiveTraceSuccess', () => {
it('should commit RECEIVE_TRACE_SUCCESS mutation ', done => {
it('should commit RECEIVE_TRACE_SUCCESS mutation ', (done) => {
testAction(
receiveTraceSuccess,
'hello world',
......@@ -417,13 +417,13 @@ describe('Job State actions', () => {
});
describe('receiveTraceError', () => {
it('should commit stop polling trace', done => {
it('should commit stop polling trace', (done) => {
testAction(receiveTraceError, null, mockedState, [], [{ type: 'stopPollingTrace' }], done);
});
});
describe('toggleCollapsibleLine', () => {
it('should commit TOGGLE_COLLAPSIBLE_LINE mutation ', done => {
it('should commit TOGGLE_COLLAPSIBLE_LINE mutation ', (done) => {
testAction(
toggleCollapsibleLine,
{ isClosed: true },
......@@ -436,7 +436,7 @@ describe('Job State actions', () => {
});
describe('requestJobsForStage', () => {
it('should commit REQUEST_JOBS_FOR_STAGE mutation ', done => {
it('should commit REQUEST_JOBS_FOR_STAGE mutation ', (done) => {
testAction(
requestJobsForStage,
{ name: 'deploy' },
......@@ -460,7 +460,7 @@ describe('Job State actions', () => {
});
describe('success', () => {
it('dispatches requestJobsForStage and receiveJobsForStageSuccess ', done => {
it('dispatches requestJobsForStage and receiveJobsForStageSuccess ', (done) => {
mock
.onGet(`${TEST_HOST}/jobs.json`)
.replyOnce(200, { latest_statuses: [{ id: 121212, name: 'build' }], retried: [] });
......@@ -490,7 +490,7 @@ describe('Job State actions', () => {
mock.onGet(`${TEST_HOST}/jobs.json`).reply(500);
});
it('dispatches requestJobsForStage and receiveJobsForStageError', done => {
it('dispatches requestJobsForStage and receiveJobsForStageError', (done) => {
testAction(
fetchJobsForStage,
{ dropdown_path: `${TEST_HOST}/jobs.json` },
......@@ -512,7 +512,7 @@ describe('Job State actions', () => {
});
describe('receiveJobsForStageSuccess', () => {
it('should commit RECEIVE_JOBS_FOR_STAGE_SUCCESS mutation ', done => {
it('should commit RECEIVE_JOBS_FOR_STAGE_SUCCESS mutation ', (done) => {
testAction(
receiveJobsForStageSuccess,
[{ id: 121212, name: 'karma' }],
......@@ -525,7 +525,7 @@ describe('Job State actions', () => {
});
describe('receiveJobsForStageError', () => {
it('should commit RECEIVE_JOBS_FOR_STAGE_ERROR mutation ', done => {
it('should commit RECEIVE_JOBS_FOR_STAGE_ERROR mutation ', (done) => {
testAction(
receiveJobsForStageError,
null,
......@@ -548,7 +548,7 @@ describe('Job State actions', () => {
mock.restore();
});
it('should dispatch fetchTrace', done => {
it('should dispatch fetchTrace', (done) => {
const playManualJobEndpoint = `${TEST_HOST}/manual-job/jobs/1000/play`;
mock.onPost(playManualJobEndpoint).reply(200);
......
import state from '~/jobs/store/state';
export const resetStore = store => {
export const resetStore = (store) => {
store.replaceState(state());
};
......@@ -4,7 +4,7 @@ import { useMockMutationObserver, useMockIntersectionObserver } from 'helpers/mo
import LazyLoader from '~/lazy_loader';
import waitForPromises from './helpers/wait_for_promises';
const execImmediately = callback => {
const execImmediately = (callback) => {
callback();
};
......@@ -20,7 +20,7 @@ describe('LazyLoader', () => {
triggerMutation(document.body, { options: { childList: true, subtree: true } });
};
const triggerIntersectionWithRatio = img => {
const triggerIntersectionWithRatio = (img) => {
triggerIntersection(img, { entry: { intersectionRatio: 0.1 } });
};
......
......@@ -15,8 +15,8 @@ const absoluteGon = {
const expectedSanitized = '<svg><use></use></svg>';
const safeUrls = {
root: Object.values(rootGon).map(url => `${url}#ellipsis_h`),
absolute: Object.values(absoluteGon).map(url => `${url}#ellipsis_h`),
root: Object.values(rootGon).map((url) => `${url}#ellipsis_h`),
absolute: Object.values(absoluteGon).map((url) => `${url}#ellipsis_h`),
};
const unsafeUrls = [
......@@ -60,7 +60,7 @@ describe('~/lib/dompurify', () => {
expect(sanitize(htmlHref)).toBe(htmlHref);
});
it.each(safeUrls[type])('allows safe URL %s', url => {
it.each(safeUrls[type])('allows safe URL %s', (url) => {
const htmlHref = `<svg><use href="${url}"></use></svg>`;
expect(sanitize(htmlHref)).toBe(htmlHref);
......@@ -68,7 +68,7 @@ describe('~/lib/dompurify', () => {
expect(sanitize(htmlXlink)).toBe(htmlXlink);
});
it.each(unsafeUrls)('sanitizes unsafe URL %s', url => {
it.each(unsafeUrls)('sanitizes unsafe URL %s', (url) => {
const htmlHref = `<svg><use href="${url}"></use></svg>`;
const htmlXlink = `<svg><use xlink:href="${url}"></use></svg>`;
......@@ -87,7 +87,7 @@ describe('~/lib/dompurify', () => {
window.gon = originalGon;
});
it.each([...safeUrls.root, ...safeUrls.absolute, ...unsafeUrls])('sanitizes URL %s', url => {
it.each([...safeUrls.root, ...safeUrls.absolute, ...unsafeUrls])('sanitizes URL %s', (url) => {
const htmlHref = `<svg><use href="${url}"></use></svg>`;
const htmlXlink = `<svg><use xlink:href="${url}"></use></svg>`;
......
......@@ -104,7 +104,7 @@ describe('AjaxCache', () => {
it('stores and returns data from Ajax call if cache is empty', () => {
mock.onGet(dummyEndpoint).reply(200, dummyResponse);
return AjaxCache.retrieve(dummyEndpoint).then(data => {
return AjaxCache.retrieve(dummyEndpoint).then((data) => {
expect(data).toEqual(dummyResponse);
expect(AjaxCache.internalStorage[dummyEndpoint]).toEqual(dummyResponse);
});
......@@ -126,7 +126,7 @@ describe('AjaxCache', () => {
mock.onGet(dummyEndpoint).networkError();
expect.assertions(2);
return AjaxCache.retrieve(dummyEndpoint).catch(error => {
return AjaxCache.retrieve(dummyEndpoint).catch((error) => {
expect(error.message).toBe(`${dummyEndpoint}: ${errorMessage}`);
expect(error.textStatus).toBe(errorMessage);
});
......@@ -135,7 +135,7 @@ describe('AjaxCache', () => {
it('makes no Ajax call if matching data exists', () => {
AjaxCache.internalStorage[dummyEndpoint] = dummyResponse;
return AjaxCache.retrieve(dummyEndpoint).then(data => {
return AjaxCache.retrieve(dummyEndpoint).then((data) => {
expect(data).toBe(dummyResponse);
expect(axios.get).not.toHaveBeenCalled();
});
......@@ -153,7 +153,7 @@ describe('AjaxCache', () => {
return Promise.all([
AjaxCache.retrieve(dummyEndpoint),
AjaxCache.retrieve(dummyEndpoint, true),
]).then(data => {
]).then((data) => {
expect(data).toEqual([oldDummyResponse, dummyResponse]);
});
});
......
......@@ -267,7 +267,7 @@ describe('common_utils', () => {
});
describe('debounceByAnimationFrame', () => {
it('debounces a function to allow a maximum of one call per animation frame', done => {
it('debounces a function to allow a maximum of one call per animation frame', (done) => {
const spy = jest.fn();
const debouncedSpy = commonUtils.debounceByAnimationFrame(spy);
window.requestAnimationFrame(() => {
......@@ -404,54 +404,54 @@ describe('common_utils', () => {
describe('backOff', () => {
beforeEach(() => {
// shortcut our timeouts otherwise these tests will take a long time to finish
jest.spyOn(window, 'setTimeout').mockImplementation(cb => setImmediate(cb, 0));
jest.spyOn(window, 'setTimeout').mockImplementation((cb) => setImmediate(cb, 0));
});
it('solves the promise from the callback', done => {
it('solves the promise from the callback', (done) => {
const expectedResponseValue = 'Success!';
commonUtils
.backOff((next, stop) =>
new Promise(resolve => {
new Promise((resolve) => {
resolve(expectedResponseValue);
})
.then(resp => {
.then((resp) => {
stop(resp);
})
.catch(done.fail),
)
.then(respBackoff => {
.then((respBackoff) => {
expect(respBackoff).toBe(expectedResponseValue);
done();
})
.catch(done.fail);
});
it('catches the rejected promise from the callback ', done => {
it('catches the rejected promise from the callback ', (done) => {
const errorMessage = 'Mistakes were made!';
commonUtils
.backOff((next, stop) => {
new Promise((resolve, reject) => {
reject(new Error(errorMessage));
})
.then(resp => {
.then((resp) => {
stop(resp);
})
.catch(err => stop(err));
.catch((err) => stop(err));
})
.catch(errBackoffResp => {
.catch((errBackoffResp) => {
expect(errBackoffResp instanceof Error).toBe(true);
expect(errBackoffResp.message).toBe(errorMessage);
done();
});
});
it('solves the promise correctly after retrying a third time', done => {
it('solves the promise correctly after retrying a third time', (done) => {
let numberOfCalls = 1;
const expectedResponseValue = 'Success!';
commonUtils
.backOff((next, stop) =>
Promise.resolve(expectedResponseValue)
.then(resp => {
.then((resp) => {
if (numberOfCalls < 3) {
numberOfCalls += 1;
next();
......@@ -461,7 +461,7 @@ describe('common_utils', () => {
})
.catch(done.fail),
)
.then(respBackoff => {
.then((respBackoff) => {
const timeouts = window.setTimeout.mock.calls.map(([, timeout]) => timeout);
expect(timeouts).toEqual([2000, 4000]);
......@@ -471,10 +471,10 @@ describe('common_utils', () => {
.catch(done.fail);
});
it('rejects the backOff promise after timing out', done => {
it('rejects the backOff promise after timing out', (done) => {
commonUtils
.backOff(next => next(), 64000)
.catch(errBackoffResp => {
.backOff((next) => next(), 64000)
.catch((errBackoffResp) => {
const timeouts = window.setTimeout.mock.calls.map(([, timeout]) => timeout);
expect(timeouts).toEqual([2000, 4000, 8000, 16000, 32000, 32000]);
......@@ -533,8 +533,8 @@ describe('common_utils', () => {
});
describe('convertObjectProps*', () => {
const mockConversionFunction = prop => `${prop}_converted`;
const isEmptyObject = obj =>
const mockConversionFunction = (prop) => `${prop}_converted`;
const isEmptyObject = (obj) =>
typeof obj === 'object' && obj !== null && Object.keys(obj).length === 0;
const mockObjects = {
......
......@@ -64,7 +64,7 @@ describe('Date time range utils', () => {
};
Object.entries(rangeTypes).forEach(([type, examples]) => {
examples.forEach(example => expect(getRangeType(example)).toEqual(type));
examples.forEach((example) => expect(getRangeType(example)).toEqual(type));
});
});
});
......
......@@ -566,7 +566,7 @@ describe('getDatesInRange', () => {
it('applies mapper function if provided fro each item in range', () => {
const d1 = new Date('2019-01-01');
const d2 = new Date('2019-01-31');
const formatter = date => date.getDate();
const formatter = (date) => date.getDate();
const range = datetimeUtility.getDatesInRange(d1, d2, formatter);
......
......@@ -45,7 +45,7 @@ describe('DOM Utils', () => {
});
describe('canScrollUp', () => {
[1, 100].forEach(scrollTop => {
[1, 100].forEach((scrollTop) => {
it(`is true if scrollTop is > 0 (${scrollTop})`, () => {
expect(
canScrollUp({
......@@ -55,7 +55,7 @@ describe('DOM Utils', () => {
});
});
[0, -10].forEach(scrollTop => {
[0, -10].forEach((scrollTop) => {
it(`is false if scrollTop is <= 0 (${scrollTop})`, () => {
expect(
canScrollUp({
......
import { serializeForm, serializeFormObject, isEmptyValue } from '~/lib/utils/forms';
describe('lib/utils/forms', () => {
const createDummyForm = inputs => {
const createDummyForm = (inputs) => {
const form = document.createElement('form');
form.innerHTML = inputs
......@@ -9,7 +9,7 @@ describe('lib/utils/forms', () => {
let str = ``;
if (type === 'select') {
str = `<select name="${name}">`;
value.forEach(v => {
value.forEach((v) => {
if (v.length > 0) {
str += `<option value="${v}"></option> `;
}
......@@ -81,8 +81,8 @@ describe('lib/utils/forms', () => {
jest
.spyOn(FormData.prototype, 'getAll')
.mockImplementation(name =>
formData.map(elem => (elem.name === name ? elem.value : undefined)),
.mockImplementation((name) =>
formData.map((elem) => (elem.name === name ? elem.value : undefined)),
);
const data = serializeForm(form);
......
......@@ -8,13 +8,13 @@ describe('highlight', () => {
});
it(`should return an empty string in the case of invalid inputs`, () => {
[null, undefined].forEach(input => {
[null, undefined].forEach((input) => {
expect(highlight(input, 'match')).toBe('');
});
});
it(`should return the original value if match is null, undefined, or ''`, () => {
[null, undefined].forEach(match => {
[null, undefined].forEach((match) => {
expect(highlight('gitlab', match)).toBe('gitlab');
});
});
......
......@@ -34,13 +34,13 @@ describe('Icon utils', () => {
});
it('extracts svg icon path content from sprite icons', () => {
return getSvgIconPathContent(mockName).then(path => {
return getSvgIconPathContent(mockName).then((path) => {
expect(path).toBe(mockPath);
});
});
it('returns null if icon path content does not exist', () => {
return getSvgIconPathContent('missing-icon').then(path => {
return getSvgIconPathContent('missing-icon').then((path) => {
expect(path).toBe(null);
});
});
......@@ -58,22 +58,22 @@ describe('Icon utils', () => {
});
it('returns null', () => {
return getSvgIconPathContent(mockName).then(path => {
return getSvgIconPathContent(mockName).then((path) => {
expect(path).toBe(null);
});
});
it('extracts svg icon path content, after 2 attempts', () => {
return getSvgIconPathContent(mockName)
.then(path1 => {
.then((path1) => {
expect(path1).toBe(null);
return getSvgIconPathContent(mockName);
})
.then(path2 => {
.then((path2) => {
expect(path2).toBe(null);
return getSvgIconPathContent(mockName);
})
.then(path3 => {
.then((path3) => {
expect(path3).toBe(mockPath);
});
});
......
......@@ -50,7 +50,7 @@ describe('Poll', () => {
};
});
it('calls the success callback when no header for interval is provided', done => {
it('calls the success callback when no header for interval is provided', (done) => {
mockServiceCall({ status: 200 });
setup();
......@@ -62,7 +62,7 @@ describe('Poll', () => {
});
});
it('calls the error callback when the http request returns an error', done => {
it('calls the error callback when the http request returns an error', (done) => {
mockServiceCall({ status: 500 }, true);
setup();
......@@ -74,7 +74,7 @@ describe('Poll', () => {
});
});
it('skips the error callback when request is aborted', done => {
it('skips the error callback when request is aborted', (done) => {
mockServiceCall({ status: 0 }, true);
setup();
......@@ -87,7 +87,7 @@ describe('Poll', () => {
});
});
it('should call the success callback when the interval header is -1', done => {
it('should call the success callback when the interval header is -1', (done) => {
mockServiceCall({ status: 200, headers: { 'poll-interval': -1 } });
setup()
.then(() => {
......@@ -100,8 +100,8 @@ describe('Poll', () => {
});
describe('for 2xx status code', () => {
successCodes.forEach(httpCode => {
it(`starts polling when http status is ${httpCode} and interval header is provided`, done => {
successCodes.forEach((httpCode) => {
it(`starts polling when http status is ${httpCode} and interval header is provided`, (done) => {
mockServiceCall({ status: httpCode, headers: { 'poll-interval': 1 } });
const Polling = new Poll({
......@@ -129,7 +129,7 @@ describe('Poll', () => {
});
describe('with delayed initial request', () => {
it('delays the first request', async done => {
it('delays the first request', async (done) => {
mockServiceCall({ status: 200, headers: { 'poll-interval': 1 } });
const Polling = new Poll({
......@@ -158,7 +158,7 @@ describe('Poll', () => {
});
describe('stop', () => {
it('stops polling when method is called', done => {
it('stops polling when method is called', (done) => {
mockServiceCall({ status: 200, headers: { 'poll-interval': 1 } });
const Polling = new Poll({
......@@ -186,7 +186,7 @@ describe('Poll', () => {
});
describe('enable', () => {
it('should enable polling upon a response', done => {
it('should enable polling upon a response', (done) => {
mockServiceCall({ status: 200 });
const Polling = new Poll({
resource: service,
......@@ -212,7 +212,7 @@ describe('Poll', () => {
});
describe('restart', () => {
it('should restart polling when its called', done => {
it('should restart polling when its called', (done) => {
mockServiceCall({ status: 200, headers: { 'poll-interval': 1 } });
const Polling = new Poll({
......
......@@ -70,7 +70,7 @@ describe('pollUntilComplete', () => {
});
it('rejects with the error response', () =>
pollUntilComplete(endpoint).catch(error => {
pollUntilComplete(endpoint).catch((error) => {
expect(error.response.data).toBe(errorMessage);
}));
});
......
......@@ -300,13 +300,13 @@ describe('text_utility', () => {
});
it(`should return an empty string for invalid inputs`, () => {
[undefined, null, 4, {}, true, new Date()].forEach(input => {
[undefined, null, 4, {}, true, new Date()].forEach((input) => {
expect(textUtils.truncateNamespace(input)).toBe('');
});
});
it(`should not alter strings that aren't formatted as namespaces`, () => {
['', ' ', '\t', 'a', 'a \\ b'].forEach(input => {
['', ' ', '\t', 'a', 'a \\ b'].forEach((input) => {
expect(textUtils.truncateNamespace(input)).toBe(input);
});
});
......
......@@ -15,7 +15,7 @@ const shas = {
],
};
const setWindowLocation = value => {
const setWindowLocation = (value) => {
Object.defineProperty(window, 'location', {
writable: true,
value,
......@@ -337,7 +337,7 @@ describe('URL utility', () => {
describe('urlContainsSha', () => {
it('returns true when there is a valid 40-character SHA1 hash in the URL', () => {
shas.valid.forEach(sha => {
shas.valid.forEach((sha) => {
expect(
urlUtils.urlContainsSha({ url: `http://urlstuff/${sha}/moreurlstuff` }),
).toBeTruthy();
......@@ -345,7 +345,7 @@ describe('URL utility', () => {
});
it('returns false when there is not a valid 40-character SHA1 hash in the URL', () => {
shas.invalid.forEach(str => {
shas.invalid.forEach((str) => {
expect(urlUtils.urlContainsSha({ url: `http://urlstuff/${str}/moreurlstuff` })).toBeFalsy();
});
});
......@@ -356,8 +356,8 @@ describe('URL utility', () => {
let invalidUrls = [];
beforeAll(() => {
validUrls = shas.valid.map(sha => `http://urlstuff/${sha}/moreurlstuff`);
invalidUrls = shas.invalid.map(str => `http://urlstuff/${str}/moreurlstuff`);
validUrls = shas.valid.map((sha) => `http://urlstuff/${sha}/moreurlstuff`);
invalidUrls = shas.invalid.map((str) => `http://urlstuff/${str}/moreurlstuff`);
});
it('returns the valid 40-character SHA1 hash from the URL', () => {
......@@ -367,7 +367,7 @@ describe('URL utility', () => {
});
it('returns null from a URL with no valid 40-character SHA1 hash', () => {
invalidUrls.forEach(url => {
invalidUrls.forEach((url) => {
expect(urlUtils.getShaFromUrl({ url })).toBeNull();
});
});
......@@ -589,11 +589,11 @@ describe('URL utility', () => {
];
describe('with URL constructor support', () => {
it.each(safeUrls)('returns true for %s', url => {
it.each(safeUrls)('returns true for %s', (url) => {
expect(urlUtils.isSafeURL(url)).toBe(true);
});
it.each(unsafeUrls)('returns false for %s', url => {
it.each(unsafeUrls)('returns false for %s', (url) => {
expect(urlUtils.isSafeURL(url)).toBe(false);
});
});
......@@ -807,7 +807,7 @@ describe('URL utility', () => {
it.each([[httpProtocol], [httpsProtocol]])(
'when no url passed, returns correct protocol for %i from window location',
protocol => {
(protocol) => {
setWindowLocation({
protocol,
});
......
......@@ -91,7 +91,7 @@ describe('UsersCache', () => {
jest.spyOn(Api, 'users').mockImplementation((query, options) => apiSpy(query, options));
});
it('stores and returns data from API call if cache is empty', done => {
it('stores and returns data from API call if cache is empty', (done) => {
apiSpy = (query, options) => {
expect(query).toBe('');
expect(options).toEqual({
......@@ -104,7 +104,7 @@ describe('UsersCache', () => {
};
UsersCache.retrieve(dummyUsername)
.then(user => {
.then((user) => {
expect(user).toBe(dummyUser);
expect(UsersCache.internalStorage[dummyUsername]).toBe(dummyUser);
})
......@@ -112,7 +112,7 @@ describe('UsersCache', () => {
.catch(done.fail);
});
it('returns undefined if Ajax call fails and cache is empty', done => {
it('returns undefined if Ajax call fails and cache is empty', (done) => {
const dummyError = new Error('server exploded');
apiSpy = (query, options) => {
......@@ -125,21 +125,21 @@ describe('UsersCache', () => {
};
UsersCache.retrieve(dummyUsername)
.then(user => done.fail(`Received unexpected user: ${JSON.stringify(user)}`))
.catch(error => {
.then((user) => done.fail(`Received unexpected user: ${JSON.stringify(user)}`))
.catch((error) => {
expect(error).toBe(dummyError);
})
.then(done)
.catch(done.fail);
});
it('makes no Ajax call if matching data exists', done => {
it('makes no Ajax call if matching data exists', (done) => {
UsersCache.internalStorage[dummyUsername] = dummyUser;
apiSpy = () => done.fail(new Error('expected no Ajax call!'));
UsersCache.retrieve(dummyUsername)
.then(user => {
.then((user) => {
expect(user).toBe(dummyUser);
})
.then(done)
......@@ -151,11 +151,11 @@ describe('UsersCache', () => {
let apiSpy;
beforeEach(() => {
jest.spyOn(Api, 'user').mockImplementation(id => apiSpy(id));
jest.spyOn(Api, 'user').mockImplementation((id) => apiSpy(id));
});
it('stores and returns data from API call if cache is empty', done => {
apiSpy = id => {
it('stores and returns data from API call if cache is empty', (done) => {
apiSpy = (id) => {
expect(id).toBe(dummyUserId);
return Promise.resolve({
......@@ -164,7 +164,7 @@ describe('UsersCache', () => {
};
UsersCache.retrieveById(dummyUserId)
.then(user => {
.then((user) => {
expect(user).toBe(dummyUser);
expect(UsersCache.internalStorage[dummyUserId]).toBe(dummyUser);
})
......@@ -172,31 +172,31 @@ describe('UsersCache', () => {
.catch(done.fail);
});
it('returns undefined if Ajax call fails and cache is empty', done => {
it('returns undefined if Ajax call fails and cache is empty', (done) => {
const dummyError = new Error('server exploded');
apiSpy = id => {
apiSpy = (id) => {
expect(id).toBe(dummyUserId);
return Promise.reject(dummyError);
};
UsersCache.retrieveById(dummyUserId)
.then(user => done.fail(`Received unexpected user: ${JSON.stringify(user)}`))
.catch(error => {
.then((user) => done.fail(`Received unexpected user: ${JSON.stringify(user)}`))
.catch((error) => {
expect(error).toBe(dummyError);
})
.then(done)
.catch(done.fail);
});
it('makes no Ajax call if matching data exists', done => {
it('makes no Ajax call if matching data exists', (done) => {
UsersCache.internalStorage[dummyUserId] = dummyUser;
apiSpy = () => done.fail(new Error('expected no Ajax call!'));
UsersCache.retrieveById(dummyUserId)
.then(user => {
.then((user) => {
expect(user).toBe(dummyUser);
})
.then(done)
......@@ -208,11 +208,11 @@ describe('UsersCache', () => {
let apiSpy;
beforeEach(() => {
jest.spyOn(Api, 'userStatus').mockImplementation(id => apiSpy(id));
jest.spyOn(Api, 'userStatus').mockImplementation((id) => apiSpy(id));
});
it('stores and returns data from API call if cache is empty', done => {
apiSpy = id => {
it('stores and returns data from API call if cache is empty', (done) => {
apiSpy = (id) => {
expect(id).toBe(dummyUserId);
return Promise.resolve({
......@@ -221,7 +221,7 @@ describe('UsersCache', () => {
};
UsersCache.retrieveStatusById(dummyUserId)
.then(userStatus => {
.then((userStatus) => {
expect(userStatus).toBe(dummyUserStatus);
expect(UsersCache.internalStorage[dummyUserId].status).toBe(dummyUserStatus);
})
......@@ -229,25 +229,25 @@ describe('UsersCache', () => {
.catch(done.fail);
});
it('returns undefined if Ajax call fails and cache is empty', done => {
it('returns undefined if Ajax call fails and cache is empty', (done) => {
const dummyError = new Error('server exploded');
apiSpy = id => {
apiSpy = (id) => {
expect(id).toBe(dummyUserId);
return Promise.reject(dummyError);
};
UsersCache.retrieveStatusById(dummyUserId)
.then(userStatus => done.fail(`Received unexpected user: ${JSON.stringify(userStatus)}`))
.catch(error => {
.then((userStatus) => done.fail(`Received unexpected user: ${JSON.stringify(userStatus)}`))
.catch((error) => {
expect(error).toBe(dummyError);
})
.then(done)
.catch(done.fail);
});
it('makes no Ajax call if matching data exists', done => {
it('makes no Ajax call if matching data exists', (done) => {
UsersCache.internalStorage[dummyUserId] = {
status: dummyUserStatus,
};
......@@ -255,7 +255,7 @@ describe('UsersCache', () => {
apiSpy = () => done.fail(new Error('expected no Ajax call!'));
UsersCache.retrieveStatusById(dummyUserId)
.then(userStatus => {
.then((userStatus) => {
expect(userStatus).toBe(dummyUserStatus);
})
.then(done)
......
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