From 49828db524ad1d1a5dfd954e9635e0bdaedea5df Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 5 Jul 2018 12:05:57 +0000 Subject: Improves performance on MR refactor and adds specs --- spec/javascripts/diffs/store/utils_spec.js | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'spec/javascripts/diffs') diff --git a/spec/javascripts/diffs/store/utils_spec.js b/spec/javascripts/diffs/store/utils_spec.js index 5a024a0f2ad..32136d9ebff 100644 --- a/spec/javascripts/diffs/store/utils_spec.js +++ b/spec/javascripts/diffs/store/utils_spec.js @@ -176,4 +176,35 @@ describe('DiffsStoreUtils', () => { expect(linesWithReferences[1].metaData.newPos).toEqual(3); }); }); + + describe('trimFirstCharOfLineContent', () => { + it('trims the line when it starts with a space', () => { + expect(utils.trimFirstCharOfLineContent({ richText: ' diff' })).toEqual({ richText: 'diff' }); + }); + + it('trims the line when it starts with a +', () => { + expect(utils.trimFirstCharOfLineContent({ richText: '+diff' })).toEqual({ richText: 'diff' }); + }); + + it('trims the line when it starts with a -', () => { + expect(utils.trimFirstCharOfLineContent({ richText: '-diff' })).toEqual({ richText: 'diff' }); + }); + + it('does not trims the line when it starts with a letter', () => { + expect(utils.trimFirstCharOfLineContent({ richText: 'diff' })).toEqual({ richText: 'diff' }); + }); + + it('does not modify the provided object', () => { + const lineObj = { + richText: ' diff', + }; + + utils.trimFirstCharOfLineContent(lineObj); + expect(lineObj).toEqual({ richText: ' diff' }); + }); + + it('handles a undefined or null parameter', () => { + expect(utils.trimFirstCharOfLineContent()).toEqual({}); + }); + }); }); -- cgit v1.2.1