Adds helpers to remove withespace and linebreaks
This commit is contained in:
parent
d103a567d6
commit
1cc633c8ec
|
@ -1,3 +1,18 @@
|
|||
export default function removeBreakLine (data) {
|
||||
return data.replace(/\r?\n|\r/g, ' ');
|
||||
}
|
||||
/**
|
||||
* 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, ' ');
|
||||
|
|
|
@ -3,6 +3,7 @@ import store from '~/ide/stores';
|
|||
import listCollapsed from '~/ide/components/commit_sidebar/list_collapsed.vue';
|
||||
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
||||
import { file } from '../../helpers';
|
||||
import { removeWhitespace } from '../../../helpers/vue_component_helper';
|
||||
|
||||
describe('Multi-file editor commit sidebar list collapsed', () => {
|
||||
let vm;
|
||||
|
@ -23,6 +24,6 @@ describe('Multi-file editor commit sidebar list collapsed', () => {
|
|||
});
|
||||
|
||||
it('renders added & modified files count', () => {
|
||||
expect(vm.$el.textContent.replace(/\s+/g, ' ').trim()).toBe('1 1');
|
||||
expect(removeWhitespace(vm.$el.textContent).trim()).toBe('1 1');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Vue from 'vue';
|
||||
import conflictsComponent from '~/vue_merge_request_widget/components/states/mr_widget_conflicts.vue';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
import removeBreakLine from 'spec/helpers/vue_component_helper';
|
||||
import { removeBreakLine } from 'spec/helpers/vue_component_helper';
|
||||
|
||||
describe('MRWidgetConflicts', () => {
|
||||
let Component;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Vue from 'vue';
|
||||
import pipelineBlockedComponent from '~/vue_merge_request_widget/components/states/mr_widget_pipeline_blocked.vue';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
import removeBreakLine from 'spec/helpers/vue_component_helper';
|
||||
import { removeBreakLine } from 'spec/helpers/vue_component_helper';
|
||||
|
||||
describe('MRWidgetPipelineBlocked', () => {
|
||||
let vm;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Vue from 'vue';
|
||||
import ShaMismatch from '~/vue_merge_request_widget/components/states/sha_mismatch.vue';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
import removeBreakLine from 'spec/helpers/vue_component_helper';
|
||||
import { removeBreakLine } from 'spec/helpers/vue_component_helper';
|
||||
|
||||
describe('ShaMismatch', () => {
|
||||
let vm;
|
||||
|
|
Loading…
Reference in New Issue