Skip to content
Snippets Groups Projects
Commit 1cc633c8 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Clement Ho
Browse files

Adds helpers to remove withespace and linebreaks

parent d103a567
No related branches found
No related tags found
No related merge requests found
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, ' ');
Loading
Loading
@@ -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;
Loading
Loading
@@ -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');
});
});
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;
Loading
Loading
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;
Loading
Loading
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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment