diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-25 15:08:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-25 15:08:23 +0300 |
commit | b5249f2d99206a72459bc5e2bf2aeb2f06ee36f3 (patch) | |
tree | 167e5cc20708e73a24d4810211fd5d15baaf8d77 /spec/frontend/ide/utils_spec.js | |
parent | 03c3f9f501301f1da34bfec229348f8ac1b7c40d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/utils_spec.js')
-rw-r--r-- | spec/frontend/ide/utils_spec.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/frontend/ide/utils_spec.js b/spec/frontend/ide/utils_spec.js index 4ae440ff09e..0b46e2cc02f 100644 --- a/spec/frontend/ide/utils_spec.js +++ b/spec/frontend/ide/utils_spec.js @@ -2,7 +2,8 @@ import { isTextFile, registerLanguages, trimPathComponents, - addFinalNewline, + insertFinalNewline, + trimTrailingWhitespace, getPathParents, } from '~/ide/utils'; import { languages } from 'monaco-editor'; @@ -155,6 +156,20 @@ describe('WebIDE utils', () => { }); }); + describe('trimTrailingWhitespace', () => { + it.each` + input | output + ${'text \n more text \n'} | ${'text\n more text\n'} + ${'text \n more text \n\n \n'} | ${'text\n more text\n\n\n'} + ${'text \t\t \n more text \n\t\ttext\n \n\t\t'} | ${'text\n more text\n\t\ttext\n\n'} + ${'text \r\n more text \r\n'} | ${'text\r\n more text\r\n'} + ${'text \r\n more text \r\n\r\n \r\n'} | ${'text\r\n more text\r\n\r\n\r\n'} + ${'text \t\t \r\n more text \r\n\t\ttext\r\n \r\n\t\t'} | ${'text\r\n more text\r\n\t\ttext\r\n\r\n'} + `("trims trailing whitespace in each line of file's contents: $input", ({ input, output }) => { + expect(trimTrailingWhitespace(input)).toBe(output); + }); + }); + describe('addFinalNewline', () => { it.each` input | output @@ -163,7 +178,7 @@ describe('WebIDE utils', () => { ${'some text\n\n'} | ${'some text\n\n'} ${'some\n text'} | ${'some\n text\n'} `('adds a newline if it doesnt already exist for input: $input', ({ input, output }) => { - expect(addFinalNewline(input)).toEqual(output); + expect(insertFinalNewline(input)).toBe(output); }); it.each` @@ -174,7 +189,7 @@ describe('WebIDE utils', () => { ${'some text\r\n\r\n'} | ${'some text\r\n\r\n'} ${'some\r\n text'} | ${'some\r\n text\r\n'} `('works with CRLF newline style; input: $input', ({ input, output }) => { - expect(addFinalNewline(input, '\r\n')).toEqual(output); + expect(insertFinalNewline(input, '\r\n')).toBe(output); }); }); |