diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-09 21:10:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-09 21:10:09 +0300 |
commit | f67f18d9492786e635e942beefa63d41f4c35765 (patch) | |
tree | 7fb6cf67d62508295b2e79f4041474ed4aa16f29 /spec/javascripts | |
parent | 4a14cfd1959c6a03758d0a75afe7b4277cf113ec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/helpers/class_spec_helper.js | 9 | ||||
-rw-r--r-- | spec/javascripts/helpers/filtered_search_spec_helper.js | 1 | ||||
-rw-r--r-- | spec/javascripts/helpers/index.js | 3 | ||||
-rw-r--r-- | spec/javascripts/helpers/init_vue_mr_page_helper.js | 46 | ||||
-rw-r--r-- | spec/javascripts/helpers/locale_helper.js | 11 | ||||
-rw-r--r-- | spec/javascripts/helpers/set_timeout_promise_helper.js | 4 | ||||
-rw-r--r-- | spec/javascripts/helpers/text_helper.js | 18 | ||||
-rw-r--r-- | spec/javascripts/helpers/tracking_helper.js | 5 | ||||
-rw-r--r-- | spec/javascripts/helpers/user_mock_data_helper.js | 14 | ||||
-rw-r--r-- | spec/javascripts/helpers/vue_mount_component_helper.js | 2 | ||||
-rw-r--r-- | spec/javascripts/helpers/vue_test_utils_helper.js | 5 | ||||
-rw-r--r-- | spec/javascripts/helpers/vuex_action_helper.js | 102 | ||||
-rw-r--r-- | spec/javascripts/helpers/wait_for_promises.js | 1 | ||||
-rw-r--r-- | spec/javascripts/jobs/mock_data.js | 2 | ||||
-rw-r--r-- | spec/javascripts/matchers.js | 55 |
15 files changed, 0 insertions, 278 deletions
diff --git a/spec/javascripts/helpers/class_spec_helper.js b/spec/javascripts/helpers/class_spec_helper.js deleted file mode 100644 index 7a60d33b471..00000000000 --- a/spec/javascripts/helpers/class_spec_helper.js +++ /dev/null @@ -1,9 +0,0 @@ -export default class ClassSpecHelper { - static itShouldBeAStaticMethod(base, method) { - return it('should be a static method', () => { - expect(Object.prototype.hasOwnProperty.call(base, method)).toBeTruthy(); - }); - } -} - -window.ClassSpecHelper = ClassSpecHelper; diff --git a/spec/javascripts/helpers/filtered_search_spec_helper.js b/spec/javascripts/helpers/filtered_search_spec_helper.js deleted file mode 100644 index de17518ea51..00000000000 --- a/spec/javascripts/helpers/filtered_search_spec_helper.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from '../../frontend/helpers/filtered_search_spec_helper'; diff --git a/spec/javascripts/helpers/index.js b/spec/javascripts/helpers/index.js deleted file mode 100644 index d2c5caf0bdb..00000000000 --- a/spec/javascripts/helpers/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import mountComponent, { mountComponentWithStore } from './vue_mount_component_helper'; - -export { mountComponent, mountComponentWithStore }; diff --git a/spec/javascripts/helpers/init_vue_mr_page_helper.js b/spec/javascripts/helpers/init_vue_mr_page_helper.js deleted file mode 100644 index 1ba08199764..00000000000 --- a/spec/javascripts/helpers/init_vue_mr_page_helper.js +++ /dev/null @@ -1,46 +0,0 @@ -import MockAdapter from 'axios-mock-adapter'; -import initMRPage from '~/mr_notes/index'; -import axios from '~/lib/utils/axios_utils'; -import { userDataMock, notesDataMock, noteableDataMock } from '../../frontend/notes/mock_data'; -import diffFileMockData from '../../frontend/diffs/mock_data/diff_file'; - -export default function initVueMRPage() { - const mrTestEl = document.createElement('div'); - mrTestEl.className = 'js-merge-request-test'; - document.body.appendChild(mrTestEl); - - const diffsAppEndpoint = '/diffs/app/endpoint'; - const diffsAppProjectPath = 'testproject'; - const mrEl = document.createElement('div'); - mrEl.className = 'merge-request fixture-mr'; - mrEl.setAttribute('data-mr-action', 'diffs'); - mrTestEl.appendChild(mrEl); - - const mrDiscussionsEl = document.createElement('div'); - mrDiscussionsEl.id = 'js-vue-mr-discussions'; - mrDiscussionsEl.setAttribute('data-current-user-data', JSON.stringify(userDataMock)); - mrDiscussionsEl.setAttribute('data-noteable-data', JSON.stringify(noteableDataMock)); - mrDiscussionsEl.setAttribute('data-notes-data', JSON.stringify(notesDataMock)); - mrDiscussionsEl.setAttribute('data-noteable-type', 'merge-request'); - mrTestEl.appendChild(mrDiscussionsEl); - - const discussionCounterEl = document.createElement('div'); - discussionCounterEl.id = 'js-vue-discussion-counter'; - mrTestEl.appendChild(discussionCounterEl); - - const diffsAppEl = document.createElement('div'); - diffsAppEl.id = 'js-diffs-app'; - diffsAppEl.setAttribute('data-endpoint', diffsAppEndpoint); - diffsAppEl.setAttribute('data-project-path', diffsAppProjectPath); - diffsAppEl.setAttribute('data-current-user-data', JSON.stringify(userDataMock)); - mrTestEl.appendChild(diffsAppEl); - - const mock = new MockAdapter(axios); - mock.onGet(diffsAppEndpoint).reply(200, { - branch_name: 'foo', - diff_files: [diffFileMockData], - }); - - initMRPage(); - return mock; -} diff --git a/spec/javascripts/helpers/locale_helper.js b/spec/javascripts/helpers/locale_helper.js deleted file mode 100644 index 80047b06003..00000000000 --- a/spec/javascripts/helpers/locale_helper.js +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable import/prefer-default-export */ - -export const setLanguage = languageCode => { - const htmlElement = document.querySelector('html'); - - if (languageCode) { - htmlElement.setAttribute('lang', languageCode); - } else { - htmlElement.removeAttribute('lang'); - } -}; diff --git a/spec/javascripts/helpers/set_timeout_promise_helper.js b/spec/javascripts/helpers/set_timeout_promise_helper.js deleted file mode 100644 index 47087619187..00000000000 --- a/spec/javascripts/helpers/set_timeout_promise_helper.js +++ /dev/null @@ -1,4 +0,0 @@ -export default (time = 0) => - new Promise(resolve => { - setTimeout(resolve, time); - }); diff --git a/spec/javascripts/helpers/text_helper.js b/spec/javascripts/helpers/text_helper.js deleted file mode 100644 index e0fe18e5560..00000000000 --- a/spec/javascripts/helpers/text_helper.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Replaces line break with an empty space - * @param {*} data - */ -export const removeBreakLine = data => data.replace(/\r?\n|\r/g, ' '); - -/** - * Removes line breaks, spaces and trims the given text - * @param {String} str - * @returns {String} - */ -export const trimText = str => - str - .replace(/\r?\n|\r/g, '') - .replace(/\s\s+/g, ' ') - .trim(); - -export const removeWhitespace = str => str.replace(/\s\s+/g, ' '); diff --git a/spec/javascripts/helpers/tracking_helper.js b/spec/javascripts/helpers/tracking_helper.js deleted file mode 100644 index ea322de46f4..00000000000 --- a/spec/javascripts/helpers/tracking_helper.js +++ /dev/null @@ -1,5 +0,0 @@ -// No new code should be added to this file. Instead, modify the -// file this one re-exports from. For more detail about why, see: -// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/31349 - -export * from '../../frontend/helpers/tracking_helper'; diff --git a/spec/javascripts/helpers/user_mock_data_helper.js b/spec/javascripts/helpers/user_mock_data_helper.js deleted file mode 100644 index 6999fa1f8a1..00000000000 --- a/spec/javascripts/helpers/user_mock_data_helper.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - createNumberRandomUsers(numberUsers) { - const users = []; - for (let i = 0; i < numberUsers; i += 1) { - users.push({ - avatar: 'https://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - id: i + 1, - name: `GitLab User ${i}`, - username: `gitlab${i}`, - }); - } - return users; - }, -}; diff --git a/spec/javascripts/helpers/vue_mount_component_helper.js b/spec/javascripts/helpers/vue_mount_component_helper.js deleted file mode 100644 index c1857115b61..00000000000 --- a/spec/javascripts/helpers/vue_mount_component_helper.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from '../../frontend/helpers/vue_mount_component_helper'; -export * from '../../frontend/helpers/vue_mount_component_helper'; diff --git a/spec/javascripts/helpers/vue_test_utils_helper.js b/spec/javascripts/helpers/vue_test_utils_helper.js deleted file mode 100644 index 1f5d8716dd3..00000000000 --- a/spec/javascripts/helpers/vue_test_utils_helper.js +++ /dev/null @@ -1,5 +0,0 @@ -// No new code should be added to this file. Instead, modify the -// file this one re-exports from. For more detail about why, see: -// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/31349 - -export * from '../../frontend/helpers/vue_test_utils_helper'; diff --git a/spec/javascripts/helpers/vuex_action_helper.js b/spec/javascripts/helpers/vuex_action_helper.js deleted file mode 100644 index c5de31a4138..00000000000 --- a/spec/javascripts/helpers/vuex_action_helper.js +++ /dev/null @@ -1,102 +0,0 @@ -const noop = () => {}; - -/** - * Helper for testing action with expected mutations inspired in - * https://vuex.vuejs.org/en/testing.html - * - * @param {Function} action to be tested - * @param {Object} payload will be provided to the action - * @param {Object} state will be provided to the action - * @param {Array} [expectedMutations=[]] mutations expected to be committed - * @param {Array} [expectedActions=[]] actions expected to be dispatched - * @param {Function} [done=noop] to be executed after the tests - * @return {Promise} - * - * @example - * testAction( - * actions.actionName, // action - * { }, // mocked payload - * state, //state - * // expected mutations - * [ - * { type: types.MUTATION} - * { type: types.MUTATION_1, payload: jasmine.any(Number)} - * ], - * // expected actions - * [ - * { type: 'actionName', payload: {param: 'foobar'}}, - * { type: 'actionName1'} - * ] - * done, - * ); - * - * @example - * testAction( - * actions.actionName, // action - * { }, // mocked payload - * state, //state - * [ { type: types.MUTATION} ], // expected mutations - * [], // expected actions - * ).then(done) - * .catch(done.fail); - */ -export default ( - action, - payload, - state, - expectedMutations = [], - expectedActions = [], - done = noop, -) => { - const mutations = []; - const actions = []; - - // mock commit - const commit = (type, mutationPayload) => { - const mutation = { type }; - - if (typeof mutationPayload !== 'undefined') { - mutation.payload = mutationPayload; - } - - mutations.push(mutation); - }; - - // mock dispatch - const dispatch = (type, actionPayload) => { - const dispatchedAction = { type }; - - if (typeof actionPayload !== 'undefined') { - dispatchedAction.payload = actionPayload; - } - - actions.push(dispatchedAction); - }; - - const validateResults = () => { - expect({ - mutations, - actions, - }).toEqual({ - mutations: expectedMutations, - actions: expectedActions, - }); - done(); - }; - - const result = action( - { commit, state, dispatch, rootState: state, rootGetters: state, getters: state }, - payload, - ); - - return new Promise(setImmediate) - .then(() => result) - .catch(error => { - validateResults(); - throw error; - }) - .then(data => { - validateResults(); - return data; - }); -}; diff --git a/spec/javascripts/helpers/wait_for_promises.js b/spec/javascripts/helpers/wait_for_promises.js deleted file mode 100644 index 1d2b53fc770..00000000000 --- a/spec/javascripts/helpers/wait_for_promises.js +++ /dev/null @@ -1 +0,0 @@ -export default () => new Promise(resolve => requestAnimationFrame(resolve)); diff --git a/spec/javascripts/jobs/mock_data.js b/spec/javascripts/jobs/mock_data.js deleted file mode 100644 index f0ba46c058a..00000000000 --- a/spec/javascripts/jobs/mock_data.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from '../../frontend/jobs/mock_data'; -export * from '../../frontend/jobs/mock_data'; diff --git a/spec/javascripts/matchers.js b/spec/javascripts/matchers.js index 7d1921cabcf..5b7b7dc78b1 100644 --- a/spec/javascripts/matchers.js +++ b/spec/javascripts/matchers.js @@ -1,61 +1,6 @@ import pixelmatch from 'pixelmatch'; export default { - toContainText: () => ({ - compare(vm, text) { - if (!(vm.$el instanceof HTMLElement)) { - throw new Error('vm.$el is not a DOM element!'); - } - - const result = { - pass: vm.$el.innerText.includes(text), - }; - return result; - }, - }), - toHaveSpriteIcon: () => ({ - compare(element, iconName) { - if (!iconName) { - throw new Error('toHaveSpriteIcon is missing iconName argument!'); - } - - if (!(element instanceof HTMLElement)) { - throw new Error(`${element} is not a DOM element!`); - } - - const iconReferences = [].slice.apply(element.querySelectorAll('svg use')); - const matchingIcon = iconReferences.find(reference => - reference.getAttribute('xlink:href').endsWith(`#${iconName}`), - ); - const result = { - pass: Boolean(matchingIcon), - }; - - if (result.pass) { - result.message = `${element.outerHTML} contains the sprite icon "${iconName}"!`; - } else { - result.message = `${element.outerHTML} does not contain the sprite icon "${iconName}"!`; - - const existingIcons = iconReferences.map(reference => { - const iconUrl = reference.getAttribute('xlink:href'); - return `"${iconUrl.replace(/^.+#/, '')}"`; - }); - if (existingIcons.length > 0) { - result.message += ` (only found ${existingIcons.join(',')})`; - } - } - - return result; - }, - }), - toRender: () => ({ - compare(vm) { - const result = { - pass: vm.$el.nodeType !== Node.COMMENT_NODE, - }; - return result; - }, - }), toImageDiffEqual: () => { const getImageData = img => { const canvas = document.createElement('canvas'); |