Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-24 00:10:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-24 00:10:24 +0300
commit5838993b5f3e2d861d9dd7c82dfeea71506b9fc2 (patch)
treecaab6621fb79f06a355f802dc885982f746b544d /spec/frontend/mocks
parentb8d021cb606ac86f41a0ef9dacd133a9677f8414 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/mocks')
-rw-r--r--spec/frontend/mocks/ce/lib/utils/axios_utils.js14
-rw-r--r--spec/frontend/mocks/mocks_helper.js6
-rw-r--r--spec/frontend/mocks/mocks_helper_spec.js10
3 files changed, 15 insertions, 15 deletions
diff --git a/spec/frontend/mocks/ce/lib/utils/axios_utils.js b/spec/frontend/mocks/ce/lib/utils/axios_utils.js
index 85fad231d28..674563b9f28 100644
--- a/spec/frontend/mocks/ce/lib/utils/axios_utils.js
+++ b/spec/frontend/mocks/ce/lib/utils/axios_utils.js
@@ -5,7 +5,7 @@ const axios = jest.requireActual('~/lib/utils/axios_utils').default;
axios.isMock = true;
// Fail tests for unmocked requests
-axios.defaults.adapter = config => {
+axios.defaults.adapter = (config) => {
const message =
`Unexpected unmocked request: ${JSON.stringify(config, null, 2)}\n` +
'Consider using the `axios-mock-adapter` module in tests.';
@@ -23,7 +23,7 @@ const onRequest = () => {
};
// Use setImmediate to alloow the response interceptor to finish
-const onResponse = config => {
+const onResponse = (config) => {
activeRequests -= 1;
setImmediate(() => {
events.emit('response', config);
@@ -31,7 +31,7 @@ const onResponse = config => {
};
const subscribeToResponse = (predicate = () => true) =>
- new Promise(resolve => {
+ new Promise((resolve) => {
const listener = (config = {}) => {
if (predicate(config)) {
events.off('response', listener);
@@ -49,7 +49,7 @@ const subscribeToResponse = (predicate = () => true) =>
/**
* Registers a callback function to be run after a request to the given URL finishes.
*/
-axios.waitFor = url => subscribeToResponse(({ url: configUrl }) => configUrl === url);
+axios.waitFor = (url) => subscribeToResponse(({ url: configUrl }) => configUrl === url);
/**
* Registers a callback function to be run after all requests have finished. If there are no requests waiting, the callback is executed immediately.
@@ -58,18 +58,18 @@ axios.waitForAll = () => subscribeToResponse(() => activeRequests === 0);
axios.countActiveRequests = () => activeRequests;
-axios.interceptors.request.use(config => {
+axios.interceptors.request.use((config) => {
onRequest();
return config;
});
// Remove the global counter
axios.interceptors.response.use(
- response => {
+ (response) => {
onResponse(response.config);
return response;
},
- err => {
+ (err) => {
onResponse(err.config);
return Promise.reject(err);
},
diff --git a/spec/frontend/mocks/mocks_helper.js b/spec/frontend/mocks/mocks_helper.js
index 0aa80331434..295483cd64c 100644
--- a/spec/frontend/mocks/mocks_helper.js
+++ b/spec/frontend/mocks/mocks_helper.js
@@ -19,9 +19,9 @@ const prefixMap = [
// { mocksRoot: 'virtual', requirePrefix: '' }, // We'll deal with virtual mocks later
];
-const mockFileFilter = stats => stats.isFile() && stats.path.endsWith('.js');
+const mockFileFilter = (stats) => stats.isFile() && stats.path.endsWith('.js');
-const getMockFiles = root => readdir.sync(root, { deep: MAX_DEPTH, filter: mockFileFilter });
+const getMockFiles = (root) => readdir.sync(root, { deep: MAX_DEPTH, filter: mockFileFilter });
// Function that performs setting a mock. This has to be overridden by the unit test, because
// jest.setMock can't be overwritten across files.
@@ -36,7 +36,7 @@ export const setupManualMocks = function setupManualMocks(setMock = defaultSetMo
return;
}
- getMockFiles(path.join(__dirname, mocksRoot)).forEach(mockPath => {
+ getMockFiles(path.join(__dirname, mocksRoot)).forEach((mockPath) => {
const mockPathNoExt = mockPath.substring(0, mockPath.length - path.extname(mockPath).length);
const sourcePath = path.join(requirePrefix, mockPathNoExt);
const mockPathRelative = `./${path.join(mocksRoot, mockPathNoExt)}`;
diff --git a/spec/frontend/mocks/mocks_helper_spec.js b/spec/frontend/mocks/mocks_helper_spec.js
index a91e8ecfa4a..0abe5c6b949 100644
--- a/spec/frontend/mocks/mocks_helper_spec.js
+++ b/spec/frontend/mocks/mocks_helper_spec.js
@@ -47,13 +47,13 @@ describe('mocks_helper.js', () => {
const readdirSpy = readdir.sync;
expect(readdirSpy).toHaveBeenCalled();
- readdirSpy.mock.calls.forEach(call => {
+ readdirSpy.mock.calls.forEach((call) => {
expect(call[1].deep).toBeLessThan(100);
});
});
it('sets up mocks for CE (the ~/ prefix)', () => {
- fs.existsSync.mockImplementation(root => root.endsWith('ce'));
+ fs.existsSync.mockImplementation((root) => root.endsWith('ce'));
readdir.sync.mockReturnValue(['root.js', 'lib/utils/util.js']);
setupManualMocks();
@@ -72,7 +72,7 @@ describe('mocks_helper.js', () => {
};
fs.existsSync.mockReturnValue(true);
- readdir.sync.mockImplementation(root => files[root]);
+ readdir.sync.mockImplementation((root) => files[root]);
setupManualMocks();
expect(readdir.sync).toHaveBeenCalledTimes(1);
@@ -84,7 +84,7 @@ describe('mocks_helper.js', () => {
});
it('fails when given a virtual mock', () => {
- fs.existsSync.mockImplementation(p => p.endsWith('ce'));
+ fs.existsSync.mockImplementation((p) => p.endsWith('ce'));
readdir.sync.mockReturnValue(['virtual', 'shouldntBeImported']);
setMock.mockImplementation(() => {
throw new Error('Could not locate module');
@@ -106,7 +106,7 @@ describe('mocks_helper.js', () => {
});
});
- it('survives jest.isolateModules()', done => {
+ it('survives jest.isolateModules()', (done) => {
jest.isolateModules(() => {
const axios2 = require('~/lib/utils/axios_utils').default;
expect(axios2.isMock).toBe(true);