Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 21:10:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 21:10:39 +0300
commit9beaa6816987274f2b870146ac649c970d69da24 (patch)
tree17af5519819903593a71b1eae47cbc0999f9a1c7 /spec/frontend/lib
parent524a21e75209d2501b23b648daf753e3a4bebe56 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/text_markdown_spec.js36
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/frontend/lib/utils/text_markdown_spec.js b/spec/frontend/lib/utils/text_markdown_spec.js
index 9fbb3d0a660..7aab1013fc0 100644
--- a/spec/frontend/lib/utils/text_markdown_spec.js
+++ b/spec/frontend/lib/utils/text_markdown_spec.js
@@ -192,9 +192,10 @@ describe('init markdown', () => {
});
describe('Continuing markdown lists', () => {
- const enterEvent = new KeyboardEvent('keydown', { key: 'Enter' });
+ let enterEvent;
beforeEach(() => {
+ enterEvent = new KeyboardEvent('keydown', { key: 'Enter', cancelable: true });
textArea.addEventListener('keydown', keypressNoteText);
textArea.addEventListener('compositionstart', compositionStartNoteText);
textArea.addEventListener('compositionend', compositionEndNoteText);
@@ -256,7 +257,7 @@ describe('init markdown', () => {
${'108. item\n109. '} | ${'108. item\n'}
${'108. item\n - second\n - '} | ${'108. item\n - second\n'}
${'108. item\n 1. second\n 1. '} | ${'108. item\n 1. second\n'}
- `('adds correct list continuation characters', ({ text, expected }) => {
+ `('remove list continuation characters', ({ text, expected }) => {
textArea.value = text;
textArea.setSelectionRange(text.length, text.length);
@@ -300,6 +301,37 @@ describe('init markdown', () => {
},
);
+ // test that when pressing Enter in the prefix area of a list item,
+ // such as between `2.`, we simply propagate the Enter,
+ // adding a newline. Since the event doesn't actually get propagated
+ // in the test, check that `defaultPrevented` is false
+ it.each`
+ text | add_at | prevented
+ ${'- one\n- two\n- three'} | ${6} | ${false}
+ ${'- one\n- two\n- three'} | ${7} | ${false}
+ ${'- one\n- two\n- three'} | ${8} | ${true}
+ ${'- [ ] one\n- [ ] two\n- [ ] three'} | ${10} | ${false}
+ ${'- [ ] one\n- [ ] two\n- [ ] three'} | ${15} | ${false}
+ ${'- [ ] one\n- [ ] two\n- [ ] three'} | ${16} | ${true}
+ ${'- [ ] one\n - [ ] two\n- [ ] three'} | ${10} | ${false}
+ ${'- [ ] one\n - [ ] two\n- [ ] three'} | ${11} | ${false}
+ ${'- [ ] one\n - [ ] two\n- [ ] three'} | ${17} | ${false}
+ ${'- [ ] one\n - [ ] two\n- [ ] three'} | ${18} | ${true}
+ ${'1. one\n2. two\n3. three'} | ${7} | ${false}
+ ${'1. one\n2. two\n3. three'} | ${9} | ${false}
+ ${'1. one\n2. two\n3. three'} | ${10} | ${true}
+ `(
+ 'allows a newline to be added if cursor is inside the list marker prefix area',
+ ({ text, add_at, prevented }) => {
+ textArea.value = text;
+ textArea.setSelectionRange(add_at, add_at);
+
+ textArea.dispatchEvent(enterEvent);
+
+ expect(enterEvent.defaultPrevented).toBe(prevented);
+ },
+ );
+
it('does not duplicate a line item for IME characters', () => {
const text = '- 日本語';
const expected = '- 日本語\n- ';