diff options
author | Johann Hubert Sonntagbauer <johann.sonntagbauer@gmail.com> | 2018-10-24 19:24:54 +0200 |
---|---|---|
committer | Johann Hubert Sonntagbauer <johann.sonntagbauer@gmail.com> | 2018-10-24 19:25:52 +0200 |
commit | 861772846bd7725eb630a0bda40a3be1ec112af4 (patch) | |
tree | 990dd0ee1b08bd8dbf13bfd378c8f50b412be3e2 /spec/javascripts/lib | |
parent | 3e18ac0e9ac04b4efce4c55748b8db12c5e42c3e (diff) | |
download | gitlab-ce-861772846bd7725eb630a0bda40a3be1ec112af4.tar.gz |
Link button in markdown editor recognize URLs
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/text_markdown_spec.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/text_markdown_spec.js b/spec/javascripts/lib/utils/text_markdown_spec.js index bb7a29fe30a..b9e805628f8 100644 --- a/spec/javascripts/lib/utils/text_markdown_spec.js +++ b/spec/javascripts/lib/utils/text_markdown_spec.js @@ -166,6 +166,33 @@ describe('init markdown', () => { expect(textArea.selectionStart).toEqual(expectedText.lastIndexOf(select)); expect(textArea.selectionEnd).toEqual(expectedText.lastIndexOf(select) + select.length); }); + + it('should support selected urls', () => { + const expectedUrl = 'http://www.gitlab.com'; + const expectedSelectionText = 'text'; + const expectedText = `text [${expectedSelectionText}](${expectedUrl}) text`; + const initialValue = `text ${expectedUrl} text`; + + textArea.value = initialValue; + const selectedIndex = initialValue.indexOf(expectedUrl); + textArea.setSelectionRange(selectedIndex, selectedIndex + expectedUrl.length); + + insertMarkdownText({ + textArea, + text: textArea.value, + tag, + blockTag: null, + selected: expectedUrl, + wrap: false, + select, + }); + + expect(textArea.value).toEqual(expectedText); + expect(textArea.selectionStart).toEqual(expectedText.indexOf(expectedSelectionText, 1)); + expect(textArea.selectionEnd).toEqual( + expectedText.indexOf(expectedSelectionText, 1) + expectedSelectionText.length, + ); + }); }); }); }); |