Commit 43329054 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'leipert-unnecessary-karma' into 'master'

Delete unused karma code

See merge request gitlab-org/gitlab!36322
parents 7c694b50 ed1dd601
import MockAdapter from 'axios-mock-adapter';
import initMRPage from '~/mr_notes/index';
import initMRPage from '~/mr_notes';
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';
import { userDataMock, notesDataMock, noteableDataMock } from '../notes/mock_data';
import diffFileMockData from '../diffs/mock_data/diff_file';
export default function initVueMRPage() {
const mrTestEl = document.createElement('div');
......
......@@ -5,7 +5,7 @@ import MergeRequestTabs from '~/merge_request_tabs';
import '~/commit/pipelines/pipelines_bundle';
import '~/lib/utils/common_utils';
import 'vendor/jquery.scrollTo';
import initMrPage from '../javascripts/helpers/init_vue_mr_page_helper';
import initMrPage from 'helpers/init_vue_mr_page_helper';
jest.mock('~/lib/utils/webpack', () => ({
resetServiceWorkersPublicPath: jest.fn(),
......
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;
export { default } from '../../frontend/helpers/filtered_search_spec_helper';
import mountComponent, { mountComponentWithStore } from './vue_mount_component_helper';
export { mountComponent, mountComponentWithStore };
/* 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');
}
};
export default (time = 0) =>
new Promise(resolve => {
setTimeout(resolve, time);
});
/**
* 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, ' ');
// 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';
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;
},
};
export { default } from '../../frontend/helpers/vue_mount_component_helper';
export * from '../../frontend/helpers/vue_mount_component_helper';
// 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';
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;
});
};
export default () => new Promise(resolve => requestAnimationFrame(resolve));
export { default } from '../../frontend/jobs/mock_data';
export * from '../../frontend/jobs/mock_data';
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');
......
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