diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-24 00:10:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-24 00:10:24 +0300 |
commit | 5838993b5f3e2d861d9dd7c82dfeea71506b9fc2 (patch) | |
tree | caab6621fb79f06a355f802dc885982f746b544d /spec/frontend/lib | |
parent | b8d021cb606ac86f41a0ef9dacd133a9677f8414 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r-- | spec/frontend/lib/dompurify_spec.js | 10 | ||||
-rw-r--r-- | spec/frontend/lib/utils/ajax_cache_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/lib/utils/apollo_startup_js_link_spec.js | 72 | ||||
-rw-r--r-- | spec/frontend/lib/utils/common_utils_spec.js | 36 | ||||
-rw-r--r-- | spec/frontend/lib/utils/datetime_range_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/lib/utils/datetime_utility_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/lib/utils/dom_utils_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/lib/utils/forms_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/lib/utils/highlight_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/lib/utils/icon_utils_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/lib/utils/poll_spec.js | 20 | ||||
-rw-r--r-- | spec/frontend/lib/utils/poll_until_complete_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/lib/utils/text_utility_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/lib/utils/url_utility_spec.js | 18 | ||||
-rw-r--r-- | spec/frontend/lib/utils/users_cache_spec.js | 54 |
15 files changed, 128 insertions, 128 deletions
diff --git a/spec/frontend/lib/dompurify_spec.js b/spec/frontend/lib/dompurify_spec.js index ee1971a4931..a01f86678e9 100644 --- a/spec/frontend/lib/dompurify_spec.js +++ b/spec/frontend/lib/dompurify_spec.js @@ -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>`; diff --git a/spec/frontend/lib/utils/ajax_cache_spec.js b/spec/frontend/lib/utils/ajax_cache_spec.js index e2ee70b9d69..641dd3684fa 100644 --- a/spec/frontend/lib/utils/ajax_cache_spec.js +++ b/spec/frontend/lib/utils/ajax_cache_spec.js @@ -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]); }); }); diff --git a/spec/frontend/lib/utils/apollo_startup_js_link_spec.js b/spec/frontend/lib/utils/apollo_startup_js_link_spec.js index faead3ff8fe..c0e5b06651f 100644 --- a/spec/frontend/lib/utils/apollo_startup_js_link_spec.js +++ b/spec/frontend/lib/utils/apollo_startup_js_link_spec.js @@ -58,9 +58,9 @@ describe('StartupJSLink', () => { link = ApolloLink.from([startupLink, new ApolloLink(() => Observable.of(FORWARDED_RESPONSE))]); }; - it('forwards requests if no calls are set up', done => { + it('forwards requests if no calls are set up', (done) => { setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls).toBe(null); expect(startupLink.request).toEqual(StartupJSLink.noopRequest); @@ -68,7 +68,7 @@ describe('StartupJSLink', () => { }); }); - it('forwards requests if the operation is not pre-loaded', done => { + it('forwards requests if the operation is not pre-loaded', (done) => { window.gl = { startup_graphql_calls: [ { @@ -79,7 +79,7 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ operationName: 'notLoaded' })).subscribe(result => { + link.request(mockOperation({ operationName: 'notLoaded' })).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(1); done(); @@ -87,7 +87,7 @@ describe('StartupJSLink', () => { }); describe('variable match errors: ', () => { - it('forwards requests if the variables are not matching', done => { + it('forwards requests if the variables are not matching', (done) => { window.gl = { startup_graphql_calls: [ { @@ -98,14 +98,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards requests if more variables are set in the operation', done => { + it('forwards requests if more variables are set in the operation', (done) => { window.gl = { startup_graphql_calls: [ { @@ -115,14 +115,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards requests if less variables are set in the operation', done => { + it('forwards requests if less variables are set in the operation', (done) => { window.gl = { startup_graphql_calls: [ { @@ -133,14 +133,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ variables: { id: 3 } })).subscribe(result => { + link.request(mockOperation({ variables: { id: 3 } })).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards requests if different variables are set', done => { + it('forwards requests if different variables are set', (done) => { window.gl = { startup_graphql_calls: [ { @@ -151,14 +151,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ variables: { id: 3 } })).subscribe(result => { + link.request(mockOperation({ variables: { id: 3 } })).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards requests if array variables have a different order', done => { + it('forwards requests if array variables have a different order', (done) => { window.gl = { startup_graphql_calls: [ { @@ -169,7 +169,7 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ variables: { id: [4, 3] } })).subscribe(result => { + link.request(mockOperation({ variables: { id: [4, 3] } })).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); @@ -178,7 +178,7 @@ describe('StartupJSLink', () => { }); describe('error handling', () => { - it('forwards the call if the fetchCall is failing with a HTTP Error', done => { + it('forwards the call if the fetchCall is failing with a HTTP Error', (done) => { window.gl = { startup_graphql_calls: [ { @@ -189,14 +189,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards the call if it errors (e.g. failing JSON)', done => { + it('forwards the call if it errors (e.g. failing JSON)', (done) => { window.gl = { startup_graphql_calls: [ { @@ -207,14 +207,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('forwards the call if the response contains an error', done => { + it('forwards the call if the response contains an error', (done) => { window.gl = { startup_graphql_calls: [ { @@ -225,14 +225,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it("forwards the call if the response doesn't contain a data object", done => { + it("forwards the call if the response doesn't contain a data object", (done) => { window.gl = { startup_graphql_calls: [ { @@ -243,7 +243,7 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(FORWARDED_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); @@ -251,7 +251,7 @@ describe('StartupJSLink', () => { }); }); - it('resolves the request if the operation is matching', done => { + it('resolves the request if the operation is matching', (done) => { window.gl = { startup_graphql_calls: [ { @@ -262,14 +262,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('resolves the request exactly once', done => { + it('resolves the request exactly once', (done) => { window.gl = { startup_graphql_calls: [ { @@ -280,17 +280,17 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation()).subscribe(result => { + link.request(mockOperation()).subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); - link.request(mockOperation()).subscribe(result2 => { + link.request(mockOperation()).subscribe((result2) => { expect(result2).toEqual(FORWARDED_RESPONSE); done(); }); }); }); - it('resolves the request if the variables have a different order', done => { + it('resolves the request if the variables have a different order', (done) => { window.gl = { startup_graphql_calls: [ { @@ -301,14 +301,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ variables: { name: 'foo', id: 3 } })).subscribe(result => { + link.request(mockOperation({ variables: { name: 'foo', id: 3 } })).subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('resolves the request if the variables have undefined values', done => { + it('resolves the request if the variables have undefined values', (done) => { window.gl = { startup_graphql_calls: [ { @@ -321,14 +321,14 @@ describe('StartupJSLink', () => { setupLink(); link .request(mockOperation({ variables: { name: 'foo', undef: undefined } })) - .subscribe(result => { + .subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('resolves the request if the variables are of an array format', done => { + it('resolves the request if the variables are of an array format', (done) => { window.gl = { startup_graphql_calls: [ { @@ -339,14 +339,14 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ variables: { id: [3, 4] } })).subscribe(result => { + link.request(mockOperation({ variables: { id: [3, 4] } })).subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); }); }); - it('resolves multiple requests correctly', done => { + it('resolves multiple requests correctly', (done) => { window.gl = { startup_graphql_calls: [ { @@ -362,10 +362,10 @@ describe('StartupJSLink', () => { ], }; setupLink(); - link.request(mockOperation({ operationName: OPERATION_NAME_TWO })).subscribe(result => { + link.request(mockOperation({ operationName: OPERATION_NAME_TWO })).subscribe((result) => { expect(result).toEqual(STARTUP_JS_RESPONSE_TWO); expect(startupLink.startupCalls.size).toBe(1); - link.request(mockOperation({ operationName: OPERATION_NAME })).subscribe(result2 => { + link.request(mockOperation({ operationName: OPERATION_NAME })).subscribe((result2) => { expect(result2).toEqual(STARTUP_JS_RESPONSE); expect(startupLink.startupCalls.size).toBe(0); done(); diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js index 433fb368f55..ddb0495fd1f 100644 --- a/spec/frontend/lib/utils/common_utils_spec.js +++ b/spec/frontend/lib/utils/common_utils_spec.js @@ -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 = { diff --git a/spec/frontend/lib/utils/datetime_range_spec.js b/spec/frontend/lib/utils/datetime_range_spec.js index 8b1f284615d..996a8e2e47b 100644 --- a/spec/frontend/lib/utils/datetime_range_spec.js +++ b/spec/frontend/lib/utils/datetime_range_spec.js @@ -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)); }); }); }); diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js index 6092b44720f..698d6cd277f 100644 --- a/spec/frontend/lib/utils/datetime_utility_spec.js +++ b/spec/frontend/lib/utils/datetime_utility_spec.js @@ -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); diff --git a/spec/frontend/lib/utils/dom_utils_spec.js b/spec/frontend/lib/utils/dom_utils_spec.js index f5c2a797df5..7c4c20e651f 100644 --- a/spec/frontend/lib/utils/dom_utils_spec.js +++ b/spec/frontend/lib/utils/dom_utils_spec.js @@ -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({ diff --git a/spec/frontend/lib/utils/forms_spec.js b/spec/frontend/lib/utils/forms_spec.js index a69be99ab98..f65bd8ffe0c 100644 --- a/spec/frontend/lib/utils/forms_spec.js +++ b/spec/frontend/lib/utils/forms_spec.js @@ -1,7 +1,7 @@ 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); diff --git a/spec/frontend/lib/utils/highlight_spec.js b/spec/frontend/lib/utils/highlight_spec.js index 638bbf65ae9..f34e203f9a4 100644 --- a/spec/frontend/lib/utils/highlight_spec.js +++ b/spec/frontend/lib/utils/highlight_spec.js @@ -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'); }); }); diff --git a/spec/frontend/lib/utils/icon_utils_spec.js b/spec/frontend/lib/utils/icon_utils_spec.js index f798dc6744d..db1f174703b 100644 --- a/spec/frontend/lib/utils/icon_utils_spec.js +++ b/spec/frontend/lib/utils/icon_utils_spec.js @@ -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); }); }); diff --git a/spec/frontend/lib/utils/poll_spec.js b/spec/frontend/lib/utils/poll_spec.js index 135c752b5cb..f2ca5df3672 100644 --- a/spec/frontend/lib/utils/poll_spec.js +++ b/spec/frontend/lib/utils/poll_spec.js @@ -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({ diff --git a/spec/frontend/lib/utils/poll_until_complete_spec.js b/spec/frontend/lib/utils/poll_until_complete_spec.js index c1df30756fd..38203c460e3 100644 --- a/spec/frontend/lib/utils/poll_until_complete_spec.js +++ b/spec/frontend/lib/utils/poll_until_complete_spec.js @@ -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); })); }); diff --git a/spec/frontend/lib/utils/text_utility_spec.js b/spec/frontend/lib/utils/text_utility_spec.js index 9c50bf577dc..1f3659b5c76 100644 --- a/spec/frontend/lib/utils/text_utility_spec.js +++ b/spec/frontend/lib/utils/text_utility_spec.js @@ -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); }); }); diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js index 0f9290e36b5..5846acbdb79 100644 --- a/spec/frontend/lib/utils/url_utility_spec.js +++ b/spec/frontend/lib/utils/url_utility_spec.js @@ -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, }); diff --git a/spec/frontend/lib/utils/users_cache_spec.js b/spec/frontend/lib/utils/users_cache_spec.js index 7ed87123482..bc00a5d5409 100644 --- a/spec/frontend/lib/utils/users_cache_spec.js +++ b/spec/frontend/lib/utils/users_cache_spec.js @@ -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) |