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>2023-02-08 21:07:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-08 21:07:53 +0300
commita3487798aeff89daff78749e6d6f392d3ca23687 (patch)
treefe7695c195931ee803aa862fc2bf977853b18a87 /spec/frontend/lib
parentc6c5dd8848b78528d7ad7f044a0c95be629d372e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/select2_utils_spec.js101
1 files changed, 0 insertions, 101 deletions
diff --git a/spec/frontend/lib/utils/select2_utils_spec.js b/spec/frontend/lib/utils/select2_utils_spec.js
deleted file mode 100644
index f8a87316655..00000000000
--- a/spec/frontend/lib/utils/select2_utils_spec.js
+++ /dev/null
@@ -1,101 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import $ from 'jquery';
-import { setHTMLFixture } from 'helpers/fixtures';
-import waitForPromises from 'helpers/wait_for_promises';
-import axios from '~/lib/utils/axios_utils';
-import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
-import { select2AxiosTransport } from '~/lib/utils/select2_utils';
-
-import 'select2/select2';
-
-const TEST_URL = '/test/api/url';
-const TEST_SEARCH_DATA = { extraSearch: 'test' };
-const TEST_DATA = [{ id: 1 }];
-const TEST_SEARCH = 'FOO';
-
-describe('lib/utils/select2_utils', () => {
- let mock;
- let resultsSpy;
-
- beforeEach(() => {
- setHTMLFixture('<div><input id="root" /></div>');
-
- mock = new MockAdapter(axios);
-
- resultsSpy = jest.fn().mockReturnValue({ results: [] });
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- const setupSelect2 = (input) => {
- input.select2({
- ajax: {
- url: TEST_URL,
- quietMillis: 250,
- transport: select2AxiosTransport,
- data(search, page) {
- return {
- search,
- page,
- ...TEST_SEARCH_DATA,
- };
- },
- results: resultsSpy,
- },
- });
- };
-
- const setupSelect2AndSearch = async () => {
- const $input = $('#root');
-
- setupSelect2($input);
-
- $input.select2('search', TEST_SEARCH);
-
- jest.runOnlyPendingTimers();
- await waitForPromises();
- };
-
- describe('select2AxiosTransport', () => {
- it('uses axios to make request', async () => {
- // setup mock response
- const replySpy = jest.fn();
- mock.onGet(TEST_URL).reply((...args) => replySpy(...args));
-
- await setupSelect2AndSearch();
-
- expect(replySpy).toHaveBeenCalledWith(
- expect.objectContaining({
- url: TEST_URL,
- method: 'get',
- params: {
- page: 1,
- search: TEST_SEARCH,
- ...TEST_SEARCH_DATA,
- },
- }),
- );
- });
-
- it.each`
- headers | pagination
- ${{}} | ${{ more: false }}
- ${{ 'X-PAGE': '1', 'x-next-page': 2 }} | ${{ more: true }}
- `(
- 'passes results and pagination to results callback, with headers=$headers',
- async ({ headers, pagination }) => {
- mock.onGet(TEST_URL).reply(HTTP_STATUS_OK, TEST_DATA, headers);
-
- await setupSelect2AndSearch();
-
- expect(resultsSpy).toHaveBeenCalledWith(
- { results: TEST_DATA, pagination },
- 1,
- expect.anything(),
- );
- },
- );
- });
-});