diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-07-05 12:05:57 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-07-05 12:05:57 +0000 |
commit | 49828db524ad1d1a5dfd954e9635e0bdaedea5df (patch) | |
tree | bf8304e1078b1bb1a8018f8179cbeb89aa518db4 /spec/javascripts | |
parent | 8b0e2628099c34a9ac352b6a9a05605613c45a53 (diff) | |
download | gitlab-ce-49828db524ad1d1a5dfd954e9635e0bdaedea5df.tar.gz |
Improves performance on MR refactor and adds specs
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/diffs/store/utils_spec.js | 31 |
1 files changed, 31 insertions, 0 deletions
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({}); + }); + }); }); |