Commit b6a8d9ba authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 44 files - 58 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 9180eaee
...@@ -1706,52 +1706,6 @@ spec/frontend/behaviors/markdown/paste_markdown_table_spec.js ...@@ -1706,52 +1706,6 @@ spec/frontend/behaviors/markdown/paste_markdown_table_spec.js
spec/frontend/behaviors/quick_submit_spec.js spec/frontend/behaviors/quick_submit_spec.js
spec/frontend/behaviors/secret_values_spec.js spec/frontend/behaviors/secret_values_spec.js
## determined-blackburn
spec/frontend/filtered_search/filtered_search_manager_spec.js
spec/frontend/filtered_search/filtered_search_token_keys_spec.js
spec/frontend/filtered_search/filtered_search_visual_tokens_spec.js
spec/frontend/filtered_search/issues_filtered_search_token_keys_spec.js
spec/frontend/filtered_search/recent_searches_root_spec.js
spec/frontend/filtered_search/services/recent_searches_service_spec.js
spec/frontend/filtered_search/visual_token_value_spec.js
spec/frontend/flash_spec.js
spec/frontend/frequent_items/components/app_spec.js
spec/frontend/frequent_items/components/frequent_items_list_item_spec.js
spec/frontend/frequent_items/components/frequent_items_search_input_spec.js
spec/frontend/frequent_items/store/actions_spec.js
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gl_field_errors_spec.js
spec/frontend/gl_form_spec.js
spec/frontend/gpg_badges_spec.js
spec/frontend/group_settings/components/shared_runners_form_spec.js
spec/frontend/groups/components/group_item_spec.js
spec/frontend/groups/components/visibility_level_dropdown_spec.js
spec/frontend/helpers/backoff_helper.js
spec/frontend/helpers/dom_events_helper.js
spec/frontend/helpers/dom_shims/size_properties.js
spec/frontend/helpers/emoji.js
spec/frontend/helpers/event_hub_factory_spec.js
spec/frontend/helpers/fake_date.js
spec/frontend/helpers/fake_request_animation_frame.js
spec/frontend/helpers/fixtures.js
spec/frontend/helpers/jest_helpers.js
spec/frontend/helpers/local_storage_helper.js
spec/frontend/helpers/locale_helper.js
spec/frontend/helpers/mock_window_location_helper.js
spec/frontend/helpers/set_timeout_promise_helper.js
spec/frontend/helpers/set_window_location_helper_spec.js
spec/frontend/helpers/startup_css_helper_spec.js
spec/frontend/helpers/stub_children.js
spec/frontend/helpers/text_helper.js
spec/frontend/helpers/timeout.js
spec/frontend/helpers/tracking_helper.js
spec/frontend/helpers/vue_mock_directive.js
spec/frontend/helpers/vue_test_utils_helper.js
spec/frontend/helpers/vuex_action_helper.js
spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_using_real_timer.js
## condescending-haslett ## condescending-haslett
spec/frontend/ide/components/activity_bar_spec.js spec/frontend/ide/components/activity_bar_spec.js
spec/frontend/ide/components/branches/search_list_spec.js spec/frontend/ide/components/branches/search_list_spec.js
......
...@@ -188,11 +188,11 @@ describe('Filtered Search Manager', () => { ...@@ -188,11 +188,11 @@ describe('Filtered Search Manager', () => {
const defaultParams = '?scope=all&utf8=%E2%9C%93'; const defaultParams = '?scope=all&utf8=%E2%9C%93';
const defaultState = '&state=opened'; const defaultState = '&state=opened';
it('should search with a single word', done => { it('should search with a single word', (done) => {
initializeManager(); initializeManager();
input.value = 'searchTerm'; input.value = 'searchTerm';
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual(`${defaultParams}&search=searchTerm`); expect(url).toEqual(`${defaultParams}&search=searchTerm`);
done(); done();
}); });
...@@ -200,11 +200,11 @@ describe('Filtered Search Manager', () => { ...@@ -200,11 +200,11 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('sets default state', done => { it('sets default state', (done) => {
initializeManager({ useDefaultState: true }); initializeManager({ useDefaultState: true });
input.value = 'searchTerm'; input.value = 'searchTerm';
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual(`${defaultParams}${defaultState}&search=searchTerm`); expect(url).toEqual(`${defaultParams}${defaultState}&search=searchTerm`);
done(); done();
}); });
...@@ -212,11 +212,11 @@ describe('Filtered Search Manager', () => { ...@@ -212,11 +212,11 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('should search with multiple words', done => { it('should search with multiple words', (done) => {
initializeManager(); initializeManager();
input.value = 'awesome search terms'; input.value = 'awesome search terms';
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual(`${defaultParams}&search=awesome+search+terms`); expect(url).toEqual(`${defaultParams}&search=awesome+search+terms`);
done(); done();
}); });
...@@ -224,11 +224,11 @@ describe('Filtered Search Manager', () => { ...@@ -224,11 +224,11 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('should search with special characters', done => { it('should search with special characters', (done) => {
initializeManager(); initializeManager();
input.value = '~!@#$%^&*()_+{}:<>,.?/'; input.value = '~!@#$%^&*()_+{}:<>,.?/';
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual( expect(url).toEqual(
`${defaultParams}&search=~!%40%23%24%25%5E%26*()_%2B%7B%7D%3A%3C%3E%2C.%3F%2F`, `${defaultParams}&search=~!%40%23%24%25%5E%26*()_%2B%7B%7D%3A%3C%3E%2C.%3F%2F`,
); );
...@@ -238,13 +238,13 @@ describe('Filtered Search Manager', () => { ...@@ -238,13 +238,13 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('should use replacement URL for condition', done => { it('should use replacement URL for condition', (done) => {
initializeManager(); initializeManager();
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML( tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(
FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', '=', '13', true), FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', '=', '13', true),
); );
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual(`${defaultParams}&milestone_title=replaced`); expect(url).toEqual(`${defaultParams}&milestone_title=replaced`);
done(); done();
}); });
...@@ -259,14 +259,14 @@ describe('Filtered Search Manager', () => { ...@@ -259,14 +259,14 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('removes duplicated tokens', done => { it('removes duplicated tokens', (done) => {
initializeManager(); initializeManager();
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(` tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(`
${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')} ${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')}
${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')} ${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')}
`); `);
visitUrl.mockImplementation(url => { visitUrl.mockImplementation((url) => {
expect(url).toEqual(`${defaultParams}&label_name[]=bug`); expect(url).toEqual(`${defaultParams}&label_name[]=bug`);
done(); done();
}); });
...@@ -605,7 +605,7 @@ describe('Filtered Search Manager', () => { ...@@ -605,7 +605,7 @@ describe('Filtered Search Manager', () => {
it('correctly modifies params when custom modifier is passed', () => { it('correctly modifies params when custom modifier is passed', () => {
const modifedParams = manager.getAllParams.call( const modifedParams = manager.getAllParams.call(
{ {
modifyUrlParams: params => params.reverse(), modifyUrlParams: (params) => params.reverse(),
}, },
[].concat(paramsArr), [].concat(paramsArr),
); );
......
...@@ -33,7 +33,7 @@ describe('Filtered Search Token Keys', () => { ...@@ -33,7 +33,7 @@ describe('Filtered Search Token Keys', () => {
describe('getKeys', () => { describe('getKeys', () => {
it('should return keys', () => { it('should return keys', () => {
const getKeys = new FilteredSearchTokenKeys(tokenKeys).getKeys(); const getKeys = new FilteredSearchTokenKeys(tokenKeys).getKeys();
const keys = new FilteredSearchTokenKeys(tokenKeys).get().map(i => i.key); const keys = new FilteredSearchTokenKeys(tokenKeys).get().map((i) => i.key);
keys.forEach((key, i) => { keys.forEach((key, i) => {
expect(key).toEqual(getKeys[i]); expect(key).toEqual(getKeys[i]);
......
...@@ -7,7 +7,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -7,7 +7,7 @@ describe('Filtered Search Visual Tokens', () => {
let mock; let mock;
const subject = FilteredSearchVisualTokens; const subject = FilteredSearchVisualTokens;
const findElements = tokenElement => { const findElements = (tokenElement) => {
const tokenNameElement = tokenElement.querySelector('.name'); const tokenNameElement = tokenElement.querySelector('.name');
const tokenOperatorElement = tokenElement.querySelector('.operator'); const tokenOperatorElement = tokenElement.querySelector('.operator');
const tokenValueContainer = tokenElement.querySelector('.value-container'); const tokenValueContainer = tokenElement.querySelector('.value-container');
......
...@@ -23,7 +23,7 @@ describe('Issues Filtered Search Token Keys', () => { ...@@ -23,7 +23,7 @@ describe('Issues Filtered Search Token Keys', () => {
}); });
it('should return assignee as a string', () => { it('should return assignee as a string', () => {
const assignee = tokenKeys.find(tokenKey => tokenKey.key === 'assignee'); const assignee = tokenKeys.find((tokenKey) => tokenKey.key === 'assignee');
expect(assignee.type).toEqual('string'); expect(assignee.type).toEqual('string');
}); });
...@@ -32,7 +32,7 @@ describe('Issues Filtered Search Token Keys', () => { ...@@ -32,7 +32,7 @@ describe('Issues Filtered Search Token Keys', () => {
describe('getKeys', () => { describe('getKeys', () => {
it('should return keys', () => { it('should return keys', () => {
const getKeys = IssuableFilteredSearchTokenKeys.getKeys(); const getKeys = IssuableFilteredSearchTokenKeys.getKeys();
const keys = IssuableFilteredSearchTokenKeys.get().map(i => i.key); const keys = IssuableFilteredSearchTokenKeys.get().map((i) => i.key);
keys.forEach((key, i) => { keys.forEach((key, i) => {
expect(key).toEqual(getKeys[i]); expect(key).toEqual(getKeys[i]);
......
...@@ -16,7 +16,7 @@ describe('RecentSearchesRoot', () => { ...@@ -16,7 +16,7 @@ describe('RecentSearchesRoot', () => {
}, },
}; };
Vue.mockImplementation(options => { Vue.mockImplementation((options) => {
({ data, template } = options); ({ data, template } = options);
}); });
......
...@@ -18,49 +18,49 @@ describe('RecentSearchesService', () => { ...@@ -18,49 +18,49 @@ describe('RecentSearchesService', () => {
jest.spyOn(RecentSearchesService, 'isAvailable').mockReturnValue(true); jest.spyOn(RecentSearchesService, 'isAvailable').mockReturnValue(true);
}); });
it('should default to empty array', done => { it('should default to empty array', (done) => {
const fetchItemsPromise = service.fetch(); const fetchItemsPromise = service.fetch();
fetchItemsPromise fetchItemsPromise
.then(items => { .then((items) => {
expect(items).toEqual([]); expect(items).toEqual([]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
it('should reject when unable to parse', done => { it('should reject when unable to parse', (done) => {
jest.spyOn(localStorage, 'getItem').mockReturnValue('fail'); jest.spyOn(localStorage, 'getItem').mockReturnValue('fail');
const fetchItemsPromise = service.fetch(); const fetchItemsPromise = service.fetch();
fetchItemsPromise fetchItemsPromise
.then(done.fail) .then(done.fail)
.catch(error => { .catch((error) => {
expect(error).toEqual(expect.any(SyntaxError)); expect(error).toEqual(expect.any(SyntaxError));
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
it('should reject when service is unavailable', done => { it('should reject when service is unavailable', (done) => {
RecentSearchesService.isAvailable.mockReturnValue(false); RecentSearchesService.isAvailable.mockReturnValue(false);
service service
.fetch() .fetch()
.then(done.fail) .then(done.fail)
.catch(error => { .catch((error) => {
expect(error).toEqual(expect.any(Error)); expect(error).toEqual(expect.any(Error));
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
it('should return items from localStorage', done => { it('should return items from localStorage', (done) => {
jest.spyOn(localStorage, 'getItem').mockReturnValue('["foo", "bar"]'); jest.spyOn(localStorage, 'getItem').mockReturnValue('["foo", "bar"]');
const fetchItemsPromise = service.fetch(); const fetchItemsPromise = service.fetch();
fetchItemsPromise fetchItemsPromise
.then(items => { .then((items) => {
expect(items).toEqual(['foo', 'bar']); expect(items).toEqual(['foo', 'bar']);
}) })
.then(done) .then(done)
...@@ -74,11 +74,11 @@ describe('RecentSearchesService', () => { ...@@ -74,11 +74,11 @@ describe('RecentSearchesService', () => {
jest.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {}); jest.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {});
}); });
it('should not call .getItem', done => { it('should not call .getItem', (done) => {
RecentSearchesService.prototype RecentSearchesService.prototype
.fetch() .fetch()
.then(done.fail) .then(done.fail)
.catch(err => { .catch((err) => {
expect(err).toEqual(new RecentSearchesServiceError()); expect(err).toEqual(new RecentSearchesServiceError());
expect(localStorage.getItem).not.toHaveBeenCalled(); expect(localStorage.getItem).not.toHaveBeenCalled();
}) })
......
...@@ -7,7 +7,7 @@ import DropdownUtils from '~/filtered_search//dropdown_utils'; ...@@ -7,7 +7,7 @@ import DropdownUtils from '~/filtered_search//dropdown_utils';
import FilteredSearchSpecHelper from '../helpers/filtered_search_spec_helper'; import FilteredSearchSpecHelper from '../helpers/filtered_search_spec_helper';
describe('Filtered Search Visual Tokens', () => { describe('Filtered Search Visual Tokens', () => {
const findElements = tokenElement => { const findElements = (tokenElement) => {
const tokenNameElement = tokenElement.querySelector('.name'); const tokenNameElement = tokenElement.querySelector('.name');
const tokenValueContainer = tokenElement.querySelector('.value-container'); const tokenValueContainer = tokenElement.querySelector('.value-container');
const tokenValueElement = tokenValueContainer.querySelector('.value'); const tokenValueElement = tokenValueContainer.querySelector('.value');
...@@ -39,15 +39,15 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -39,15 +39,15 @@ describe('Filtered Search Visual Tokens', () => {
let usersCacheSpy; let usersCacheSpy;
beforeEach(() => { beforeEach(() => {
jest.spyOn(UsersCache, 'retrieve').mockImplementation(username => usersCacheSpy(username)); jest.spyOn(UsersCache, 'retrieve').mockImplementation((username) => usersCacheSpy(username));
}); });
it('ignores error if UsersCache throws', done => { it('ignores error if UsersCache throws', (done) => {
jest.spyOn(window, 'Flash').mockImplementation(() => {}); jest.spyOn(window, 'Flash').mockImplementation(() => {});
const dummyError = new Error('Earth rotated backwards'); const dummyError = new Error('Earth rotated backwards');
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
usersCacheSpy = username => { usersCacheSpy = (username) => {
expect(`@${username}`).toBe(tokenValue); expect(`@${username}`).toBe(tokenValue);
return Promise.reject(dummyError); return Promise.reject(dummyError);
}; };
...@@ -61,10 +61,10 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -61,10 +61,10 @@ describe('Filtered Search Visual Tokens', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does nothing if user cannot be found', done => { it('does nothing if user cannot be found', (done) => {
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
usersCacheSpy = username => { usersCacheSpy = (username) => {
expect(`@${username}`).toBe(tokenValue); expect(`@${username}`).toBe(tokenValue);
return Promise.resolve(undefined); return Promise.resolve(undefined);
}; };
...@@ -78,14 +78,14 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -78,14 +78,14 @@ describe('Filtered Search Visual Tokens', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('replaces author token with avatar and display name', done => { it('replaces author token with avatar and display name', (done) => {
const dummyUser = { const dummyUser = {
name: 'Important Person', name: 'Important Person',
avatar_url: 'https://host.invalid/mypics/avatar.png', avatar_url: 'https://host.invalid/mypics/avatar.png',
}; };
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
usersCacheSpy = username => { usersCacheSpy = (username) => {
expect(`@${username}`).toBe(tokenValue); expect(`@${username}`).toBe(tokenValue);
return Promise.resolve(dummyUser); return Promise.resolve(dummyUser);
}; };
...@@ -104,14 +104,14 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -104,14 +104,14 @@ describe('Filtered Search Visual Tokens', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('escapes user name when creating token', done => { it('escapes user name when creating token', (done) => {
const dummyUser = { const dummyUser = {
name: '<script>', name: '<script>',
avatar_url: `${TEST_HOST}/mypics/avatar.png`, avatar_url: `${TEST_HOST}/mypics/avatar.png`,
}; };
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
usersCacheSpy = username => { usersCacheSpy = (username) => {
expect(`@${username}`).toBe(tokenValue); expect(`@${username}`).toBe(tokenValue);
return Promise.resolve(dummyUser); return Promise.resolve(dummyUser);
}; };
...@@ -168,7 +168,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -168,7 +168,7 @@ describe('Filtered Search Visual Tokens', () => {
AjaxCache.internalStorage[`${filteredSearchInput.dataset.labelsEndpoint}.json`] = labelData; AjaxCache.internalStorage[`${filteredSearchInput.dataset.labelsEndpoint}.json`] = labelData;
}); });
const parseColor = color => { const parseColor = (color) => {
const dummyElement = document.createElement('div'); const dummyElement = document.createElement('div');
dummyElement.style.color = color; dummyElement.style.color = color;
return dummyElement.style.color; return dummyElement.style.color;
...@@ -180,10 +180,10 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -180,10 +180,10 @@ describe('Filtered Search Visual Tokens', () => {
expect(tokenValueContainer.style.color).toBe(parseColor(label.text_color)); expect(tokenValueContainer.style.color).toBe(parseColor(label.text_color));
}; };
const findLabel = tokenValue => const findLabel = (tokenValue) =>
labelData.find(label => tokenValue === `~${DropdownUtils.getEscapedText(label.title)}`); labelData.find((label) => tokenValue === `~${DropdownUtils.getEscapedText(label.title)}`);
it('updates the color of a label token', done => { it('updates the color of a label token', (done) => {
const { subject, tokenValueContainer, tokenValueElement } = findElements(bugLabelToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(bugLabelToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
const matchingLabel = findLabel(tokenValue); const matchingLabel = findLabel(tokenValue);
...@@ -197,7 +197,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -197,7 +197,7 @@ describe('Filtered Search Visual Tokens', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('updates the color of a label token with spaces', done => { it('updates the color of a label token with spaces', (done) => {
const { subject, tokenValueContainer, tokenValueElement } = findElements(spaceLabelToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(spaceLabelToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
const matchingLabel = findLabel(tokenValue); const matchingLabel = findLabel(tokenValue);
...@@ -211,7 +211,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -211,7 +211,7 @@ describe('Filtered Search Visual Tokens', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not change color of a missing label', done => { it('does not change color of a missing label', (done) => {
const { subject, tokenValueContainer, tokenValueElement } = findElements(missingLabelToken); const { subject, tokenValueContainer, tokenValueElement } = findElements(missingLabelToken);
const tokenValue = tokenValueElement.innerText; const tokenValue = tokenValueElement.innerText;
const matchingLabel = findLabel(tokenValue); const matchingLabel = findLabel(tokenValue);
...@@ -260,7 +260,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -260,7 +260,7 @@ describe('Filtered Search Visual Tokens', () => {
}); });
describe('render', () => { describe('render', () => {
const setupSpies = subject => { const setupSpies = (subject) => {
jest.spyOn(subject, 'updateLabelTokenColor').mockImplementation(() => {}); jest.spyOn(subject, 'updateLabelTokenColor').mockImplementation(() => {});
const updateLabelTokenColorSpy = subject.updateLabelTokenColor; const updateLabelTokenColorSpy = subject.updateLabelTokenColor;
......
...@@ -325,7 +325,7 @@ describe('Flash', () => { ...@@ -325,7 +325,7 @@ describe('Flash', () => {
`; `;
}); });
it('removes global flash on click', done => { it('removes global flash on click', (done) => {
const flashEl = document.querySelector('.flash'); const flashEl = document.querySelector('.flash');
removeFlashClickListener(flashEl, false); removeFlashClickListener(flashEl, false);
......
...@@ -65,7 +65,7 @@ describe('Frequent Items App Component', () => { ...@@ -65,7 +65,7 @@ describe('Frequent Items App Component', () => {
storage[storageKey] = value; storage[storageKey] = value;
}); });
localStorage.getItem.mockImplementation(storageKey => { localStorage.getItem.mockImplementation((storageKey) => {
if (storage[storageKey]) { if (storage[storageKey]) {
return storage[storageKey]; return storage[storageKey];
} }
...@@ -160,7 +160,7 @@ describe('Frequent Items App Component', () => { ...@@ -160,7 +160,7 @@ describe('Frequent Items App Component', () => {
}); });
describe('created', () => { describe('created', () => {
it('should bind event listeners on eventHub', done => { it('should bind event listeners on eventHub', (done) => {
jest.spyOn(eventHub, '$on').mockImplementation(() => {}); jest.spyOn(eventHub, '$on').mockImplementation(() => {});
createComponentWithStore().$mount(); createComponentWithStore().$mount();
...@@ -173,7 +173,7 @@ describe('Frequent Items App Component', () => { ...@@ -173,7 +173,7 @@ describe('Frequent Items App Component', () => {
}); });
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('should unbind event listeners on eventHub', done => { it('should unbind event listeners on eventHub', (done) => {
jest.spyOn(eventHub, '$off').mockImplementation(() => {}); jest.spyOn(eventHub, '$off').mockImplementation(() => {});
vm.$mount(); vm.$mount();
...@@ -191,7 +191,7 @@ describe('Frequent Items App Component', () => { ...@@ -191,7 +191,7 @@ describe('Frequent Items App Component', () => {
expect(vm.$el.querySelector('.search-input-container')).toBeDefined(); expect(vm.$el.querySelector('.search-input-container')).toBeDefined();
}); });
it('should render loading animation', done => { it('should render loading animation', (done) => {
vm.$store.dispatch('fetchSearchedItems'); vm.$store.dispatch('fetchSearchedItems');
Vue.nextTick(() => { Vue.nextTick(() => {
...@@ -204,7 +204,7 @@ describe('Frequent Items App Component', () => { ...@@ -204,7 +204,7 @@ describe('Frequent Items App Component', () => {
}); });
}); });
it('should render frequent projects list header', done => { it('should render frequent projects list header', (done) => {
Vue.nextTick(() => { Vue.nextTick(() => {
const sectionHeaderEl = vm.$el.querySelector('.section-header'); const sectionHeaderEl = vm.$el.querySelector('.section-header');
...@@ -214,7 +214,7 @@ describe('Frequent Items App Component', () => { ...@@ -214,7 +214,7 @@ describe('Frequent Items App Component', () => {
}); });
}); });
it('should render frequent projects list', done => { it('should render frequent projects list', (done) => {
const expectedResult = getTopFrequentItems(mockFrequentProjects); const expectedResult = getTopFrequentItems(mockFrequentProjects);
localStorage.getItem.mockImplementation(() => JSON.stringify(mockFrequentProjects)); localStorage.getItem.mockImplementation(() => JSON.stringify(mockFrequentProjects));
...@@ -229,7 +229,7 @@ describe('Frequent Items App Component', () => { ...@@ -229,7 +229,7 @@ describe('Frequent Items App Component', () => {
}); });
}); });
it('should render searched projects list', done => { it('should render searched projects list', (done) => {
mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(200, mockSearchedProjects); mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(200, mockSearchedProjects);
expect(vm.$el.querySelectorAll('.frequent-items-list-container li').length).toBe(1); expect(vm.$el.querySelectorAll('.frequent-items-list-container li').length).toBe(1);
......
...@@ -114,7 +114,7 @@ describe('FrequentItemsListItemComponent', () => { ...@@ -114,7 +114,7 @@ describe('FrequentItemsListItemComponent', () => {
const link = wrapper.find('a'); const link = wrapper.find('a');
// NOTE: this listener is required to prevent the click from going through and causing: // NOTE: this listener is required to prevent the click from going through and causing:
// `Error: Not implemented: navigation ...` // `Error: Not implemented: navigation ...`
link.element.addEventListener('click', e => { link.element.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
}); });
link.trigger('click'); link.trigger('click');
......
...@@ -46,7 +46,7 @@ describe('FrequentItemsSearchInputComponent', () => { ...@@ -46,7 +46,7 @@ describe('FrequentItemsSearchInputComponent', () => {
}); });
describe('mounted', () => { describe('mounted', () => {
it('should listen `dropdownOpen` event', done => { it('should listen `dropdownOpen` event', (done) => {
jest.spyOn(eventHub, '$on').mockImplementation(() => {}); jest.spyOn(eventHub, '$on').mockImplementation(() => {});
const vmX = createComponent().vm; const vmX = createComponent().vm;
...@@ -61,7 +61,7 @@ describe('FrequentItemsSearchInputComponent', () => { ...@@ -61,7 +61,7 @@ describe('FrequentItemsSearchInputComponent', () => {
}); });
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('should unbind event listeners on eventHub', done => { it('should unbind event listeners on eventHub', (done) => {
const vmX = createComponent().vm; const vmX = createComponent().vm;
jest.spyOn(eventHub, '$off').mockImplementation(() => {}); jest.spyOn(eventHub, '$off').mockImplementation(() => {});
......
...@@ -29,7 +29,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -29,7 +29,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('setNamespace', () => { describe('setNamespace', () => {
it('should set namespace', done => { it('should set namespace', (done) => {
testAction( testAction(
actions.setNamespace, actions.setNamespace,
mockNamespace, mockNamespace,
...@@ -42,7 +42,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -42,7 +42,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('setStorageKey', () => { describe('setStorageKey', () => {
it('should set storage key', done => { it('should set storage key', (done) => {
testAction( testAction(
actions.setStorageKey, actions.setStorageKey,
mockStorageKey, mockStorageKey,
...@@ -55,7 +55,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -55,7 +55,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('requestFrequentItems', () => { describe('requestFrequentItems', () => {
it('should request frequent items', done => { it('should request frequent items', (done) => {
testAction( testAction(
actions.requestFrequentItems, actions.requestFrequentItems,
null, null,
...@@ -68,7 +68,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -68,7 +68,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('receiveFrequentItemsSuccess', () => { describe('receiveFrequentItemsSuccess', () => {
it('should set frequent items', done => { it('should set frequent items', (done) => {
testAction( testAction(
actions.receiveFrequentItemsSuccess, actions.receiveFrequentItemsSuccess,
mockFrequentProjects, mockFrequentProjects,
...@@ -81,7 +81,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -81,7 +81,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('receiveFrequentItemsError', () => { describe('receiveFrequentItemsError', () => {
it('should set frequent items error state', done => { it('should set frequent items error state', (done) => {
testAction( testAction(
actions.receiveFrequentItemsError, actions.receiveFrequentItemsError,
null, null,
...@@ -94,7 +94,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -94,7 +94,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('fetchFrequentItems', () => { describe('fetchFrequentItems', () => {
it('should dispatch `receiveFrequentItemsSuccess`', done => { it('should dispatch `receiveFrequentItemsSuccess`', (done) => {
mockedState.namespace = mockNamespace; mockedState.namespace = mockNamespace;
mockedState.storageKey = mockStorageKey; mockedState.storageKey = mockStorageKey;
...@@ -108,7 +108,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -108,7 +108,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
); );
}); });
it('should dispatch `receiveFrequentItemsError`', done => { it('should dispatch `receiveFrequentItemsError`', (done) => {
jest.spyOn(AccessorUtilities, 'isLocalStorageAccessSafe').mockReturnValue(false); jest.spyOn(AccessorUtilities, 'isLocalStorageAccessSafe').mockReturnValue(false);
mockedState.namespace = mockNamespace; mockedState.namespace = mockNamespace;
mockedState.storageKey = mockStorageKey; mockedState.storageKey = mockStorageKey;
...@@ -125,7 +125,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -125,7 +125,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('requestSearchedItems', () => { describe('requestSearchedItems', () => {
it('should request searched items', done => { it('should request searched items', (done) => {
testAction( testAction(
actions.requestSearchedItems, actions.requestSearchedItems,
null, null,
...@@ -138,7 +138,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -138,7 +138,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('receiveSearchedItemsSuccess', () => { describe('receiveSearchedItemsSuccess', () => {
it('should set searched items', done => { it('should set searched items', (done) => {
testAction( testAction(
actions.receiveSearchedItemsSuccess, actions.receiveSearchedItemsSuccess,
mockSearchedProjects, mockSearchedProjects,
...@@ -151,7 +151,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -151,7 +151,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('receiveSearchedItemsError', () => { describe('receiveSearchedItemsError', () => {
it('should set searched items error state', done => { it('should set searched items error state', (done) => {
testAction( testAction(
actions.receiveSearchedItemsError, actions.receiveSearchedItemsError,
null, null,
...@@ -168,7 +168,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -168,7 +168,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
gon.api_version = 'v4'; gon.api_version = 'v4';
}); });
it('should dispatch `receiveSearchedItemsSuccess`', done => { it('should dispatch `receiveSearchedItemsSuccess`', (done) => {
mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(200, mockSearchedProjects, {}); mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(200, mockSearchedProjects, {});
testAction( testAction(
...@@ -187,7 +187,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -187,7 +187,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
); );
}); });
it('should dispatch `receiveSearchedItemsError`', done => { it('should dispatch `receiveSearchedItemsError`', (done) => {
gon.api_version = 'v4'; gon.api_version = 'v4';
mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(500); mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(500);
...@@ -203,7 +203,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -203,7 +203,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
}); });
describe('setSearchQuery', () => { describe('setSearchQuery', () => {
it('should commit query and dispatch `fetchSearchedItems` when query is present', done => { it('should commit query and dispatch `fetchSearchedItems` when query is present', (done) => {
testAction( testAction(
actions.setSearchQuery, actions.setSearchQuery,
{ query: 'test' }, { query: 'test' },
...@@ -214,7 +214,7 @@ describe('Frequent Items Dropdown Store Actions', () => { ...@@ -214,7 +214,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
); );
}); });
it('should commit query and dispatch `fetchFrequentItems` when query is empty', done => { it('should commit query and dispatch `fetchFrequentItems` when query is empty', (done) => {
testAction( testAction(
actions.setSearchQuery, actions.setSearchQuery,
null, null,
......
...@@ -164,7 +164,7 @@ describe('GfmAutoComplete', () => { ...@@ -164,7 +164,7 @@ describe('GfmAutoComplete', () => {
}); });
}); });
it.each([200, 500])('should set the loading state', async responseStatus => { it.each([200, 500])('should set the loading state', async (responseStatus) => {
mock.onGet('vulnerabilities_autocomplete_url').replyOnce(responseStatus); mock.onGet('vulnerabilities_autocomplete_url').replyOnce(responseStatus);
fetchData.call(context, {}, '[vulnerability:', 'query'); fetchData.call(context, {}, '[vulnerability:', 'query');
...@@ -371,9 +371,9 @@ describe('GfmAutoComplete', () => { ...@@ -371,9 +371,9 @@ describe('GfmAutoComplete', () => {
const jointAllowedSymbols = allowedSymbols.join(''); const jointAllowedSymbols = allowedSymbols.join('');
describe('should match regular symbols', () => { describe('should match regular symbols', () => {
flagsUseDefaultMatcher.forEach(flag => { flagsUseDefaultMatcher.forEach((flag) => {
allowedSymbols.forEach(symbol => { allowedSymbols.forEach((symbol) => {
argumentSize.forEach(size => { argumentSize.forEach((size) => {
const query = new Array(size + 1).join(symbol); const query = new Array(size + 1).join(symbol);
const subtext = flag + query; const subtext = flag + query;
...@@ -395,8 +395,8 @@ describe('GfmAutoComplete', () => { ...@@ -395,8 +395,8 @@ describe('GfmAutoComplete', () => {
const shouldNotBeFollowedBy = flags.concat(['\x00', '\x10', '\x3f', '\n', ' ']); const shouldNotBeFollowedBy = flags.concat(['\x00', '\x10', '\x3f', '\n', ' ']);
const shouldNotBePrependedBy = ['`']; const shouldNotBePrependedBy = ['`'];
flagsUseDefaultMatcher.forEach(atSign => { flagsUseDefaultMatcher.forEach((atSign) => {
shouldNotBeFollowedBy.forEach(followedSymbol => { shouldNotBeFollowedBy.forEach((followedSymbol) => {
const seq = atSign + followedSymbol; const seq = atSign + followedSymbol;
it(`should not match ${JSON.stringify(seq)}`, () => { it(`should not match ${JSON.stringify(seq)}`, () => {
...@@ -404,7 +404,7 @@ describe('GfmAutoComplete', () => { ...@@ -404,7 +404,7 @@ describe('GfmAutoComplete', () => {
}); });
}); });
shouldNotBePrependedBy.forEach(prependedSymbol => { shouldNotBePrependedBy.forEach((prependedSymbol) => {
const seq = prependedSymbol + atSign; const seq = prependedSymbol + atSign;
it(`should not match "${seq}"`, () => { it(`should not match "${seq}"`, () => {
...@@ -638,8 +638,8 @@ describe('GfmAutoComplete', () => { ...@@ -638,8 +638,8 @@ describe('GfmAutoComplete', () => {
}; };
const allLabels = labelsFixture; const allLabels = labelsFixture;
const assignedLabels = allLabels.filter(label => label.set); const assignedLabels = allLabels.filter((label) => label.set);
const unassignedLabels = allLabels.filter(label => !label.set); const unassignedLabels = allLabels.filter((label) => !label.set);
let autocomplete; let autocomplete;
let $textarea; let $textarea;
...@@ -655,7 +655,7 @@ describe('GfmAutoComplete', () => { ...@@ -655,7 +655,7 @@ describe('GfmAutoComplete', () => {
autocomplete.destroy(); autocomplete.destroy();
}); });
const triggerDropdown = text => { const triggerDropdown = (text) => {
$textarea.trigger('focus').val(text).caret('pos', -1); $textarea.trigger('focus').val(text).caret('pos', -1);
$textarea.trigger('keyup'); $textarea.trigger('keyup');
...@@ -665,12 +665,12 @@ describe('GfmAutoComplete', () => { ...@@ -665,12 +665,12 @@ describe('GfmAutoComplete', () => {
const getDropdownItems = () => { const getDropdownItems = () => {
const dropdown = document.getElementById('at-view-labels'); const dropdown = document.getElementById('at-view-labels');
const items = dropdown.getElementsByTagName('li'); const items = dropdown.getElementsByTagName('li');
return [].map.call(items, item => item.textContent.trim()); return [].map.call(items, (item) => item.textContent.trim());
}; };
const expectLabels = ({ input, output }) => const expectLabels = ({ input, output }) =>
triggerDropdown(input).then(() => { triggerDropdown(input).then(() => {
expect(getDropdownItems()).toEqual(output.map(label => label.title)); expect(getDropdownItems()).toEqual(output.map((label) => label.title));
}); });
describe('with no labels assigned', () => { describe('with no labels assigned', () => {
...@@ -740,8 +740,8 @@ describe('GfmAutoComplete', () => { ...@@ -740,8 +740,8 @@ describe('GfmAutoComplete', () => {
describe.each` describe.each`
name | inputFormat | assert name | inputFormat | assert
${'insertTemplateFunction'} | ${name => ({ name })} | ${assertInserted} ${'insertTemplateFunction'} | ${(name) => ({ name })} | ${assertInserted}
${'templateFunction'} | ${name => name} | ${assertTemplated} ${'templateFunction'} | ${(name) => name} | ${assertTemplated}
`('Emoji.$name', ({ name, inputFormat, assert }) => { `('Emoji.$name', ({ name, inputFormat, assert }) => {
const execute = (accessor, input, emoji) => const execute = (accessor, input, emoji) =>
assert({ assert({
...@@ -808,7 +808,7 @@ describe('GfmAutoComplete', () => { ...@@ -808,7 +808,7 @@ describe('GfmAutoComplete', () => {
const item = GfmAutoComplete.Emoji.templateFunction('heart') const item = GfmAutoComplete.Emoji.templateFunction('heart')
.replace(/(<gl-emoji)\s+(data-name)/, '$1 $2') .replace(/(<gl-emoji)\s+(data-name)/, '$1 $2')
.replace(/>\s+|\s+</g, s => s.trim()); .replace(/>\s+|\s+</g, (s) => s.trim());
expect(item).toEqual( expect(item).toEqual(
`<li>${heart.name}<gl-emoji data-name="${heart.name}"></gl-emoji></li>`, `<li>${heart.name}<gl-emoji data-name="${heart.name}"></gl-emoji></li>`,
); );
...@@ -820,7 +820,7 @@ describe('GfmAutoComplete', () => { ...@@ -820,7 +820,7 @@ describe('GfmAutoComplete', () => {
const item = GfmAutoComplete.Emoji.templateFunction('star') const item = GfmAutoComplete.Emoji.templateFunction('star')
.replace(/(<gl-emoji)\s+(data-name)/, '$1 $2') .replace(/(<gl-emoji)\s+(data-name)/, '$1 $2')
.replace(/>\s+|\s+</g, s => s.trim()); .replace(/>\s+|\s+</g, (s) => s.trim());
expect(item).toEqual(`<li>${star.name}<gl-emoji data-name="${star.name}"></gl-emoji></li>`); expect(item).toEqual(`<li>${star.name}<gl-emoji data-name="${star.name}"></gl-emoji></li>`);
}); });
}); });
......
...@@ -33,7 +33,7 @@ describe('GL Style Field Errors', () => { ...@@ -33,7 +33,7 @@ describe('GL Style Field Errors', () => {
expect(customErrorElem.length).toBe(1); expect(customErrorElem.length).toBe(1);
const customErrors = testContext.fieldErrors.state.inputs.filter(input => { const customErrors = testContext.fieldErrors.state.inputs.filter((input) => {
return input.inputElement.hasClass(customErrorFlag); return input.inputElement.hasClass(customErrorFlag);
}); });
......
...@@ -8,7 +8,7 @@ describe('GLForm', () => { ...@@ -8,7 +8,7 @@ describe('GLForm', () => {
const testContext = {}; const testContext = {};
describe('when instantiated', () => { describe('when instantiated', () => {
beforeEach(done => { beforeEach((done) => {
window.gl = window.gl || {}; window.gl = window.gl || {};
testContext.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>'); testContext.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>');
...@@ -28,7 +28,7 @@ describe('GLForm', () => { ...@@ -28,7 +28,7 @@ describe('GLForm', () => {
}); });
describe('setupAutosize', () => { describe('setupAutosize', () => {
beforeEach(done => { beforeEach((done) => {
testContext.glForm.setupAutosize(); testContext.glForm.setupAutosize();
setImmediate(() => { setImmediate(() => {
......
...@@ -36,7 +36,7 @@ describe('GpgBadges', () => { ...@@ -36,7 +36,7 @@ describe('GpgBadges', () => {
mock.restore(); mock.restore();
}); });
it('does not make a request if there is no container element', done => { it('does not make a request if there is no container element', (done) => {
setFixtures(''); setFixtures('');
jest.spyOn(axios, 'get').mockImplementation(() => {}); jest.spyOn(axios, 'get').mockImplementation(() => {});
...@@ -48,13 +48,13 @@ describe('GpgBadges', () => { ...@@ -48,13 +48,13 @@ describe('GpgBadges', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('throws an error if the endpoint is missing', done => { it('throws an error if the endpoint is missing', (done) => {
setFixtures('<div class="js-signature-container"></div>'); setFixtures('<div class="js-signature-container"></div>');
jest.spyOn(axios, 'get').mockImplementation(() => {}); jest.spyOn(axios, 'get').mockImplementation(() => {});
GpgBadges.fetch() GpgBadges.fetch()
.then(() => done.fail('Expected error to be thrown')) .then(() => done.fail('Expected error to be thrown'))
.catch(error => { .catch((error) => {
expect(error.message).toBe('Missing commit signatures endpoint!'); expect(error.message).toBe('Missing commit signatures endpoint!');
expect(axios.get).not.toHaveBeenCalled(); expect(axios.get).not.toHaveBeenCalled();
}) })
...@@ -62,7 +62,7 @@ describe('GpgBadges', () => { ...@@ -62,7 +62,7 @@ describe('GpgBadges', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('displays a loading spinner', done => { it('displays a loading spinner', (done) => {
mock.onGet(dummyUrl).replyOnce(200); mock.onGet(dummyUrl).replyOnce(200);
GpgBadges.fetch() GpgBadges.fetch()
...@@ -76,7 +76,7 @@ describe('GpgBadges', () => { ...@@ -76,7 +76,7 @@ describe('GpgBadges', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('replaces the loading spinner', done => { it('replaces the loading spinner', (done) => {
mock.onGet(dummyUrl).replyOnce(200, dummyResponse); mock.onGet(dummyUrl).replyOnce(200, dummyResponse);
GpgBadges.fetch() GpgBadges.fetch()
......
...@@ -32,7 +32,7 @@ describe('group_settings/components/shared_runners_form', () => { ...@@ -32,7 +32,7 @@ describe('group_settings/components/shared_runners_form', () => {
const findErrorAlert = () => wrapper.find(GlAlert); const findErrorAlert = () => wrapper.find(GlAlert);
const findEnabledToggle = () => wrapper.find('[data-testid="enable-runners-toggle"]'); const findEnabledToggle = () => wrapper.find('[data-testid="enable-runners-toggle"]');
const findOverrideToggle = () => wrapper.find('[data-testid="override-runners-toggle"]'); const findOverrideToggle = () => wrapper.find('[data-testid="override-runners-toggle"]');
const changeToggle = toggle => toggle.vm.$emit('change', !toggle.props('value')); const changeToggle = (toggle) => toggle.vm.$emit('change', !toggle.props('value'));
const getRequestPayload = () => JSON.parse(mock.history.put[0].data); const getRequestPayload = () => JSON.parse(mock.history.put[0].data);
const isLoadingIconVisible = () => findLoadingIcon().exists(); const isLoadingIconVisible = () => findLoadingIcon().exists();
......
...@@ -31,7 +31,7 @@ describe('GroupItemComponent', () => { ...@@ -31,7 +31,7 @@ describe('GroupItemComponent', () => {
vm.$destroy(); vm.$destroy();
}); });
const withMicrodata = group => ({ const withMicrodata = (group) => ({
...group, ...group,
microdata: getGroupItemMicrodata(group), microdata: getGroupItemMicrodata(group),
}); });
...@@ -49,7 +49,7 @@ describe('GroupItemComponent', () => { ...@@ -49,7 +49,7 @@ describe('GroupItemComponent', () => {
const { rowClass } = vm; const { rowClass } = vm;
expect(Object.keys(rowClass).length).toBe(classes.length); expect(Object.keys(rowClass).length).toBe(classes.length);
Object.keys(rowClass).forEach(className => { Object.keys(rowClass).forEach((className) => {
expect(classes.indexOf(className)).toBeGreaterThan(-1); expect(classes.indexOf(className)).toBeGreaterThan(-1);
}); });
}); });
...@@ -220,13 +220,13 @@ describe('GroupItemComponent', () => { ...@@ -220,13 +220,13 @@ describe('GroupItemComponent', () => {
}); });
describe('schema.org props', () => { describe('schema.org props', () => {
describe('when showSchemaMarkup is disabled on the group', () => { describe('when showSchemaMarkup is disabled on the group', () => {
it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', attr => { it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', (attr) => {
expect(vm.$el.getAttribute(attr)).toBeNull(); expect(vm.$el.getAttribute(attr)).toBeNull();
}); });
it.each( it.each(
['.js-group-avatar', '.js-group-name', '.js-group-description'], ['.js-group-avatar', '.js-group-name', '.js-group-description'],
'it does not set `itemprop` on sub-nodes', 'it does not set `itemprop` on sub-nodes',
selector => { (selector) => {
expect(vm.$el.querySelector(selector).getAttribute('itemprop')).toBeNull(); expect(vm.$el.querySelector(selector).getAttribute('itemprop')).toBeNull();
}, },
); );
......
...@@ -11,7 +11,7 @@ describe('Visibility Level Dropdown', () => { ...@@ -11,7 +11,7 @@ describe('Visibility Level Dropdown', () => {
]; ];
const defaultLevel = 0; const defaultLevel = 0;
const createComponent = propsData => { const createComponent = (propsData) => {
wrapper = shallowMount(Component, { wrapper = shallowMount(Component, {
propsData, propsData,
}); });
...@@ -33,7 +33,7 @@ describe('Visibility Level Dropdown', () => { ...@@ -33,7 +33,7 @@ describe('Visibility Level Dropdown', () => {
wrapper.find("input[name='group[visibility_level]']").attributes('value'); wrapper.find("input[name='group[visibility_level]']").attributes('value');
const dropdownText = () => wrapper.find(GlDropdown).props('text'); const dropdownText = () => wrapper.find(GlDropdown).props('text');
const findDropdownItems = () => const findDropdownItems = () =>
wrapper.findAll(GlDropdownItem).wrappers.map(option => ({ wrapper.findAll(GlDropdownItem).wrappers.map((option) => ({
text: option.text(), text: option.text(),
secondaryText: option.props('secondaryText'), secondaryText: option.props('secondaryText'),
})); }));
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
* *
* @param {Function} callback * @param {Function} callback
*/ */
export const backoffMockImplementation = callback => { export const backoffMockImplementation = (callback) => {
const q = new Promise((resolve, reject) => { const q = new Promise((resolve, reject) => {
const stop = arg => (arg instanceof Error ? reject(arg) : resolve(arg)); const stop = (arg) => (arg instanceof Error ? reject(arg) : resolve(arg));
const next = () => callback(next, stop); const next = () => callback(next, stop);
// Define a timeout based on a mock timer // Define a timeout based on a mock timer
setTimeout(() => { setTimeout(() => {
......
export const triggerDOMEvent = type => { export const triggerDOMEvent = (type) => {
window.document.dispatchEvent( window.document.dispatchEvent(
new Event(type, { new Event(type, {
bubbles: true, bubbles: true,
......
const convertFromStyle = style => { const convertFromStyle = (style) => {
if (style.match(/[0-9](px|rem)/g)) { if (style.match(/[0-9](px|rem)/g)) {
return Number(style.replace(/[^0-9]/g, '')); return Number(style.replace(/[^0-9]/g, ''));
} }
......
...@@ -55,7 +55,7 @@ export const emojiFixtureMap = { ...@@ -55,7 +55,7 @@ export const emojiFixtureMap = {
}, },
}; };
Object.keys(emojiFixtureMap).forEach(k => { Object.keys(emojiFixtureMap).forEach((k) => {
emojiFixtureMap[k].name = k; emojiFixtureMap[k].name = k;
if (!emojiFixtureMap[k].aliases) { if (!emojiFixtureMap[k].aliases) {
emojiFixtureMap[k].aliases = []; emojiFixtureMap[k].aliases = [];
...@@ -64,7 +64,7 @@ Object.keys(emojiFixtureMap).forEach(k => { ...@@ -64,7 +64,7 @@ Object.keys(emojiFixtureMap).forEach(k => {
export async function initEmojiMock() { export async function initEmojiMock() {
const emojiData = Object.fromEntries( const emojiData = Object.fromEntries(
Object.values(emojiFixtureMap).map(m => { Object.values(emojiFixtureMap).map((m) => {
const { name: n, moji: e, unicodeVersion: u, category: c, description: d } = m; const { name: n, moji: e, unicodeVersion: u, category: c, description: d } = m;
return [n, { c, e, d, u }]; return [n, { c, e, d, u }];
}), }),
...@@ -81,8 +81,8 @@ export async function initEmojiMock() { ...@@ -81,8 +81,8 @@ export async function initEmojiMock() {
export function describeEmojiFields(label, tests) { export function describeEmojiFields(label, tests) {
describe.each` describe.each`
field | accessor field | accessor
${'name'} | ${e => e.name} ${'name'} | ${(e) => e.name}
${'alias'} | ${e => e.aliases[0]} ${'alias'} | ${(e) => e.aliases[0]}
${'description'} | ${e => e.description} ${'description'} | ${(e) => e.description}
`(label, tests); `(label, tests);
} }
...@@ -93,7 +93,7 @@ describe('event bus factory', () => { ...@@ -93,7 +93,7 @@ describe('event bus factory', () => {
describe('$off', () => { describe('$off', () => {
beforeEach(() => { beforeEach(() => {
otherHandlers.forEach(x => eventBus.$on(TEST_EVENT, x)); otherHandlers.forEach((x) => eventBus.$on(TEST_EVENT, x));
eventBus.$on(TEST_EVENT, handler); eventBus.$on(TEST_EVENT, handler);
}); });
...@@ -115,7 +115,7 @@ describe('event bus factory', () => { ...@@ -115,7 +115,7 @@ describe('event bus factory', () => {
eventBus.$emit(TEST_EVENT); eventBus.$emit(TEST_EVENT);
expect(handler).not.toHaveBeenCalled(); expect(handler).not.toHaveBeenCalled();
expect(otherHandlers.map(x => x.mock.calls.length)).toEqual(otherHandlers.map(() => 1)); expect(otherHandlers.map((x) => x.mock.calls.length)).toEqual(otherHandlers.map(() => 1));
}); });
it('without a handler, will no longer call any handlers', () => { it('without a handler, will no longer call any handlers', () => {
...@@ -124,13 +124,13 @@ describe('event bus factory', () => { ...@@ -124,13 +124,13 @@ describe('event bus factory', () => {
eventBus.$emit(TEST_EVENT); eventBus.$emit(TEST_EVENT);
expect(handler).not.toHaveBeenCalled(); expect(handler).not.toHaveBeenCalled();
expect(otherHandlers.map(x => x.mock.calls.length)).toEqual(otherHandlers.map(() => 0)); expect(otherHandlers.map((x) => x.mock.calls.length)).toEqual(otherHandlers.map(() => 0));
}); });
}); });
describe('$emit', () => { describe('$emit', () => {
beforeEach(() => { beforeEach(() => {
otherHandlers.forEach(x => eventBus.$on(TEST_EVENT_2, x)); otherHandlers.forEach((x) => eventBus.$on(TEST_EVENT_2, x));
eventBus.$on(TEST_EVENT, handler); eventBus.$on(TEST_EVENT, handler);
}); });
...@@ -138,7 +138,7 @@ describe('event bus factory', () => { ...@@ -138,7 +138,7 @@ describe('event bus factory', () => {
eventBus.$emit(TEST_EVENT, 'arg1'); eventBus.$emit(TEST_EVENT, 'arg1');
expect(handler).toHaveBeenCalledWith('arg1'); expect(handler).toHaveBeenCalledWith('arg1');
expect(otherHandlers.map(x => x.mock.calls.length)).toEqual(otherHandlers.map(() => 0)); expect(otherHandlers.map((x) => x.mock.calls.length)).toEqual(otherHandlers.map(() => 0));
}); });
}); });
}); });
...@@ -3,9 +3,9 @@ export const DEFAULT_ARGS = [2020, 6, 6]; ...@@ -3,9 +3,9 @@ export const DEFAULT_ARGS = [2020, 6, 6];
const RealDate = Date; const RealDate = Date;
const isMocked = val => Boolean(val.mock); const isMocked = (val) => Boolean(val.mock);
export const createFakeDateClass = ctorDefault => { export const createFakeDateClass = (ctorDefault) => {
const FakeDate = new Proxy(RealDate, { const FakeDate = new Proxy(RealDate, {
construct: (target, argArray) => { construct: (target, argArray) => {
const ctorArgs = argArray.length ? argArray : ctorDefault; const ctorArgs = argArray.length ? argArray : ctorDefault;
...@@ -25,7 +25,7 @@ export const createFakeDateClass = ctorDefault => { ...@@ -25,7 +25,7 @@ export const createFakeDateClass = ctorDefault => {
return target[prop]; return target[prop];
}, },
getPrototypeOf: target => { getPrototypeOf: (target) => {
return target.prototype; return target.prototype;
}, },
// We need to be able to set props so that `jest.spyOn` will work. // We need to be able to set props so that `jest.spyOn` will work.
......
...@@ -3,7 +3,7 @@ export const useFakeRequestAnimationFrame = () => { ...@@ -3,7 +3,7 @@ export const useFakeRequestAnimationFrame = () => {
beforeEach(() => { beforeEach(() => {
orig = global.requestAnimationFrame; orig = global.requestAnimationFrame;
global.requestAnimationFrame = cb => cb(); global.requestAnimationFrame = (cb) => cb();
}); });
afterEach(() => { afterEach(() => {
......
...@@ -20,7 +20,7 @@ Did you run bin/rake frontend:fixtures?`, ...@@ -20,7 +20,7 @@ Did you run bin/rake frontend:fixtures?`,
return fs.readFileSync(absolutePath, 'utf8'); return fs.readFileSync(absolutePath, 'utf8');
} }
export const getJSONFixture = relativePath => JSON.parse(getFixture(relativePath)); export const getJSONFixture = (relativePath) => JSON.parse(getFixture(relativePath));
export const resetHTMLFixture = () => { export const resetHTMLFixture = () => {
document.head.innerHTML = ''; document.head.innerHTML = '';
......
...@@ -15,7 +15,7 @@ Try not to use these in new tests - this module is provided primarily for conven ...@@ -15,7 +15,7 @@ Try not to use these in new tests - this module is provided primarily for conven
*/ */
export function createSpyObj(baseName, methods) { export function createSpyObj(baseName, methods) {
const obj = {}; const obj = {};
methods.forEach(method => { methods.forEach((method) => {
obj[method] = jest.fn().mockName(`${baseName}#${method}`); obj[method] = jest.fn().mockName(`${baseName}#${method}`);
}); });
return obj; return obj;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* @param {() => any} fn Function that returns the object to use for localStorage * @param {() => any} fn Function that returns the object to use for localStorage
*/ */
const useLocalStorage = fn => { const useLocalStorage = (fn) => {
const origLocalStorage = window.localStorage; const origLocalStorage = window.localStorage;
let currentLocalStorage = origLocalStorage; let currentLocalStorage = origLocalStorage;
...@@ -35,11 +35,11 @@ export const createLocalStorageSpy = () => { ...@@ -35,11 +35,11 @@ export const createLocalStorageSpy = () => {
clear: jest.fn(() => { clear: jest.fn(() => {
storage = {}; storage = {};
}), }),
getItem: jest.fn(key => (key in storage ? storage[key] : null)), getItem: jest.fn((key) => (key in storage ? storage[key] : null)),
setItem: jest.fn((key, value) => { setItem: jest.fn((key, value) => {
storage[key] = value; storage[key] = value;
}), }),
removeItem: jest.fn(key => delete storage[key]), removeItem: jest.fn((key) => delete storage[key]),
}; };
}; };
......
export const setLanguage = languageCode => { export const setLanguage = (languageCode) => {
const htmlElement = document.querySelector('html'); const htmlElement = document.querySelector('html');
if (languageCode) { if (languageCode) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* @param {() => any} fn Function that returns the object to use for window.location * @param {() => any} fn Function that returns the object to use for window.location
*/ */
const useMockLocation = fn => { const useMockLocation = (fn) => {
const origWindowLocation = window.location; const origWindowLocation = window.location;
let currentWindowLocation; let currentWindowLocation;
......
export default (time = 0) => export default (time = 0) =>
new Promise(resolve => { new Promise((resolve) => {
setTimeout(resolve, time); setTimeout(resolve, time);
}); });
...@@ -32,7 +32,7 @@ describe('setWindowLocation', () => { ...@@ -32,7 +32,7 @@ describe('setWindowLocation', () => {
it.each([null, 1, undefined, false, '', 'gitlab.com'])( it.each([null, 1, undefined, false, '', 'gitlab.com'])(
'throws an error when called with an invalid url: "%s"', 'throws an error when called with an invalid url: "%s"',
invalidUrl => { (invalidUrl) => {
expect(() => setWindowLocation(invalidUrl)).toThrow(/Invalid URL/); expect(() => setWindowLocation(invalidUrl)).toThrow(/Invalid URL/);
expect(window.location).toBe(originalLocation); expect(window.location).toBe(originalLocation);
}, },
......
...@@ -75,7 +75,7 @@ describe('waitForCSSLoaded', () => { ...@@ -75,7 +75,7 @@ describe('waitForCSSLoaded', () => {
const events = waitForCSSLoaded(mockedCallback); const events = waitForCSSLoaded(mockedCallback);
document document
.querySelectorAll('[data-startupcss="loading"]') .querySelectorAll('[data-startupcss="loading"]')
.forEach(elem => elem.setAttribute('data-startupcss', 'loaded')); .forEach((elem) => elem.setAttribute('data-startupcss', 'loaded'));
document.dispatchEvent(new CustomEvent('CSSStartupLinkLoaded')); document.dispatchEvent(new CustomEvent('CSSStartupLinkLoaded'));
await events; await events;
......
export default function stubChildren(Component) { export default function stubChildren(Component) {
return Object.fromEntries(Object.keys(Component.components).map(c => [c, true])); return Object.fromEntries(Object.keys(Component.components).map((c) => [c, true]));
} }
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Replaces line break with an empty space * Replaces line break with an empty space
* @param {*} data * @param {*} data
*/ */
export const removeBreakLine = data => data.replace(/\r?\n|\r/g, ' '); export const removeBreakLine = (data) => data.replace(/\r?\n|\r/g, ' ');
/** /**
* Removes line breaks, spaces and trims the given text * Removes line breaks, spaces and trims the given text
* @param {String} str * @param {String} str
* @returns {String} * @returns {String}
*/ */
export const trimText = str => export const trimText = (str) =>
str str
.replace(/\r?\n|\r/g, '') .replace(/\r?\n|\r/g, '')
.replace(/\s\s+/g, ' ') .replace(/\s\s+/g, ' ')
.trim(); .trim();
export const removeWhitespace = str => str.replace(/\s\s+/g, ' '); export const removeWhitespace = (str) => str.replace(/\s\s+/g, ' ');
...@@ -4,7 +4,7 @@ const IS_DEBUGGING = process.execArgv.join(' ').includes('--inspect-brk'); ...@@ -4,7 +4,7 @@ const IS_DEBUGGING = process.execArgv.join(' ').includes('--inspect-brk');
let testTimeoutNS; let testTimeoutNS;
export const setTestTimeout = newTimeoutMS => { export const setTestTimeout = (newTimeoutMS) => {
const newTimeoutNS = newTimeoutMS * NS_PER_MS; const newTimeoutNS = newTimeoutMS * NS_PER_MS;
// never accept a smaller timeout than the default // never accept a smaller timeout than the default
if (newTimeoutNS < testTimeoutNS) { if (newTimeoutNS < testTimeoutNS) {
...@@ -18,7 +18,7 @@ export const setTestTimeout = newTimeoutMS => { ...@@ -18,7 +18,7 @@ export const setTestTimeout = newTimeoutMS => {
// Allows slow tests to set their own timeout. // Allows slow tests to set their own timeout.
// Useful for tests with jQuery, which is very slow in big DOMs. // Useful for tests with jQuery, which is very slow in big DOMs.
let temporaryTimeoutNS = null; let temporaryTimeoutNS = null;
export const setTestTimeoutOnce = newTimeoutMS => { export const setTestTimeoutOnce = (newTimeoutMS) => {
const newTimeoutNS = newTimeoutMS * NS_PER_MS; const newTimeoutNS = newTimeoutMS * NS_PER_MS;
// never accept a smaller timeout than the default // never accept a smaller timeout than the default
if (newTimeoutNS < testTimeoutNS) { if (newTimeoutNS < testTimeoutNS) {
...@@ -28,7 +28,7 @@ export const setTestTimeoutOnce = newTimeoutMS => { ...@@ -28,7 +28,7 @@ export const setTestTimeoutOnce = newTimeoutMS => {
temporaryTimeoutNS = newTimeoutNS; temporaryTimeoutNS = newTimeoutNS;
}; };
export const initializeTestTimeout = defaultTimeoutMS => { export const initializeTestTimeout = (defaultTimeoutMS) => {
setTestTimeout(defaultTimeoutMS); setTestTimeout(defaultTimeoutMS);
let testStartTime; let testStartTime;
......
...@@ -14,7 +14,7 @@ export function mockTracking(category = '_category_', documentOverride, spyMetho ...@@ -14,7 +14,7 @@ export function mockTracking(category = '_category_', documentOverride, spyMetho
export function unmockTracking() { export function unmockTracking() {
window.snowplow = undefined; window.snowplow = undefined;
handlers.forEach(event => document.removeEventListener(event.name, event.func)); handlers.forEach((event) => document.removeEventListener(event.name, event.func));
} }
export function triggerEvent(selectorOrEl, eventName = 'click') { export function triggerEvent(selectorOrEl, eventName = 'click') {
......
export const getKey = name => `$_gl_jest_${name}`; export const getKey = (name) => `$_gl_jest_${name}`;
export const getBinding = (el, name) => el[getKey(name)]; export const getBinding = (el, name) => el[getKey(name)];
......
...@@ -2,7 +2,7 @@ import { isArray } from 'lodash'; ...@@ -2,7 +2,7 @@ import { isArray } from 'lodash';
const vNodeContainsText = (vnode, text) => const vNodeContainsText = (vnode, text) =>
(vnode.text && vnode.text.includes(text)) || (vnode.text && vnode.text.includes(text)) ||
(vnode.children && vnode.children.filter(child => vNodeContainsText(child, text)).length); (vnode.children && vnode.children.filter((child) => vNodeContainsText(child, text)).length);
/** /**
* Determines whether a `shallowMount` Wrapper contains text * Determines whether a `shallowMount` Wrapper contains text
...@@ -17,7 +17,7 @@ const vNodeContainsText = (vnode, text) => ...@@ -17,7 +17,7 @@ const vNodeContainsText = (vnode, text) =>
*/ */
export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) => export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =>
Boolean( Boolean(
shallowWrapper.vm.$slots[slotName].filter(vnode => vNodeContainsText(vnode, text)).length, shallowWrapper.vm.$slots[slotName].filter((vnode) => vNodeContainsText(vnode, text)).length,
); );
/** /**
...@@ -27,8 +27,8 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) = ...@@ -27,8 +27,8 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =
* @param {String} expectedMutationType - The Mutation to wait for * @param {String} expectedMutationType - The Mutation to wait for
*/ */
export const waitForMutation = (store, expectedMutationType) => export const waitForMutation = (store, expectedMutationType) =>
new Promise(resolve => { new Promise((resolve) => {
const unsubscribe = store.subscribe(mutation => { const unsubscribe = store.subscribe((mutation) => {
if (mutation.type === expectedMutationType) { if (mutation.type === expectedMutationType) {
unsubscribe(); unsubscribe();
resolve(); resolve();
...@@ -36,7 +36,7 @@ export const waitForMutation = (store, expectedMutationType) => ...@@ -36,7 +36,7 @@ export const waitForMutation = (store, expectedMutationType) =>
}); });
}); });
export const extendedWrapper = wrapper => { export const extendedWrapper = (wrapper) => {
if (isArray(wrapper) || !wrapper?.find) { if (isArray(wrapper) || !wrapper?.find) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.warn( console.warn(
......
...@@ -116,12 +116,12 @@ export default ( ...@@ -116,12 +116,12 @@ export default (
payload, payload,
); );
return (result || new Promise(resolve => setImmediate(resolve))) return (result || new Promise((resolve) => setImmediate(resolve)))
.catch(error => { .catch((error) => {
validateResults(); validateResults();
throw error; throw error;
}) })
.then(data => { .then((data) => {
validateResults(); validateResults();
return data; return data;
}); });
......
...@@ -10,7 +10,7 @@ const testActionFnWithOptionsArg = (...args) => { ...@@ -10,7 +10,7 @@ const testActionFnWithOptionsArg = (...args) => {
describe.each([testActionFn, testActionFnWithOptionsArg])( describe.each([testActionFn, testActionFnWithOptionsArg])(
'VueX test helper (testAction)', 'VueX test helper (testAction)',
testAction => { (testAction) => {
let originalExpect; let originalExpect;
let assertion; let assertion;
let mock; let mock;
...@@ -25,7 +25,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -25,7 +25,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
*/ */
originalExpect = expect; originalExpect = expect;
assertion = null; assertion = null;
global.expect = actual => ({ global.expect = (actual) => ({
toEqual: () => { toEqual: () => {
originalExpect(actual).toEqual(assertion); originalExpect(actual).toEqual(assertion);
}, },
...@@ -72,13 +72,13 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -72,13 +72,13 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
testAction(action, null, {}, assertion.mutations, assertion.actions, noop); testAction(action, null, {}, assertion.mutations, assertion.actions, noop);
}); });
it('works with done callback once finished', done => { it('works with done callback once finished', (done) => {
assertion = { mutations: [], actions: [] }; assertion = { mutations: [], actions: [] };
testAction(noop, null, {}, assertion.mutations, assertion.actions, done); testAction(noop, null, {}, assertion.mutations, assertion.actions, done);
}); });
it('returns a promise', done => { it('returns a promise', (done) => {
assertion = { mutations: [], actions: [] }; assertion = { mutations: [], actions: [] };
testAction(noop, null, {}, assertion.mutations, assertion.actions) testAction(noop, null, {}, assertion.mutations, assertion.actions)
...@@ -96,7 +96,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -96,7 +96,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
return axios return axios
.get(TEST_HOST) .get(TEST_HOST)
.catch(error => { .catch((error) => {
commit('ERROR'); commit('ERROR');
lastError = error; lastError = error;
throw error; throw error;
...@@ -111,7 +111,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -111,7 +111,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
lastError = null; lastError = null;
}); });
it('works with done callback once finished', done => { it('works with done callback once finished', (done) => {
mock.onGet(TEST_HOST).replyOnce(200, 42); mock.onGet(TEST_HOST).replyOnce(200, 42);
assertion = { mutations: [{ type: 'SUCCESS' }], actions: [{ type: 'ACTION' }] }; assertion = { mutations: [{ type: 'SUCCESS' }], actions: [{ type: 'ACTION' }] };
...@@ -119,34 +119,34 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -119,34 +119,34 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
testAction(asyncAction, null, {}, assertion.mutations, assertion.actions, done); testAction(asyncAction, null, {}, assertion.mutations, assertion.actions, done);
}); });
it('returns original data of successful promise while checking actions/mutations', done => { it('returns original data of successful promise while checking actions/mutations', (done) => {
mock.onGet(TEST_HOST).replyOnce(200, 42); mock.onGet(TEST_HOST).replyOnce(200, 42);
assertion = { mutations: [{ type: 'SUCCESS' }], actions: [{ type: 'ACTION' }] }; assertion = { mutations: [{ type: 'SUCCESS' }], actions: [{ type: 'ACTION' }] };
testAction(asyncAction, null, {}, assertion.mutations, assertion.actions) testAction(asyncAction, null, {}, assertion.mutations, assertion.actions)
.then(res => { .then((res) => {
originalExpect(res).toEqual(data); originalExpect(res).toEqual(data);
done(); done();
}) })
.catch(done.fail); .catch(done.fail);
}); });
it('returns original error of rejected promise while checking actions/mutations', done => { it('returns original error of rejected promise while checking actions/mutations', (done) => {
mock.onGet(TEST_HOST).replyOnce(500, ''); mock.onGet(TEST_HOST).replyOnce(500, '');
assertion = { mutations: [{ type: 'ERROR' }], actions: [{ type: 'ACTION' }] }; assertion = { mutations: [{ type: 'ERROR' }], actions: [{ type: 'ACTION' }] };
testAction(asyncAction, null, {}, assertion.mutations, assertion.actions) testAction(asyncAction, null, {}, assertion.mutations, assertion.actions)
.then(done.fail) .then(done.fail)
.catch(error => { .catch((error) => {
originalExpect(error).toBe(lastError); originalExpect(error).toBe(lastError);
done(); done();
}); });
}); });
}); });
it('works with async actions not returning promises', done => { it('works with async actions not returning promises', (done) => {
const data = { FOO: 'BAR' }; const data = { FOO: 'BAR' };
const asyncAction = ({ commit, dispatch }) => { const asyncAction = ({ commit, dispatch }) => {
...@@ -158,7 +158,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])( ...@@ -158,7 +158,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
commit('SUCCESS'); commit('SUCCESS');
return data; return data;
}) })
.catch(error => { .catch((error) => {
commit('ERROR'); commit('ERROR');
throw error; throw error;
}); });
......
export default () => new Promise(resolve => requestAnimationFrame(resolve)); export default () => new Promise((resolve) => requestAnimationFrame(resolve));
/* useful for timing promises when jest fakeTimers are not reliable enough */ /* useful for timing promises when jest fakeTimers are not reliable enough */
export default timeout => export default (timeout) =>
new Promise(resolve => { new Promise((resolve) => {
jest.useRealTimers(); jest.useRealTimers();
setTimeout(resolve, timeout); setTimeout(resolve, timeout);
jest.useFakeTimers(); jest.useFakeTimers();
......
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