summaryrefslogtreecommitdiff
path: root/spec/javascripts/lib
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-10-26 07:56:32 +0000
committerPhil Hughes <me@iamphill.com>2018-10-26 07:56:32 +0000
commit2bbfca8240c605e3b1c4aed18cadda4f6403e138 (patch)
treee2f0c8686d6b1f6ffd09fe4c6927c8133a4f8693 /spec/javascripts/lib
parentf659f8cf878bcce1e4fbf4763ec8daaeb3300f32 (diff)
parent861772846bd7725eb630a0bda40a3be1ec112af4 (diff)
downloadgitlab-ce-2bbfca8240c605e3b1c4aed18cadda4f6403e138.tar.gz
Merge branch '52115-Link-button-in-markdown-editor-should-recognize-URLs' into 'master'
Link button in markdown editor recognize URLs Closes #52115 See merge request gitlab-org/gitlab-ce!22547
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r--spec/javascripts/lib/utils/text_markdown_spec.js27
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,
+ );
+ });
});
});
});