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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-02 06:10:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-02 06:10:55 +0300
commit8f57ac0a38b7045f241dc5ad29fcde3f6eae3a40 (patch)
treec662fafed37149368629a1a9a4858c850682ee1b /spec
parent30b8ad35feb7efb0587f44d8e7b371490634ee1c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/lib/utils/text_markdown_spec.js53
-rw-r--r--spec/models/user_spec.rb6
2 files changed, 39 insertions, 20 deletions
diff --git a/spec/frontend/lib/utils/text_markdown_spec.js b/spec/frontend/lib/utils/text_markdown_spec.js
index 43de195c702..b538257fac0 100644
--- a/spec/frontend/lib/utils/text_markdown_spec.js
+++ b/spec/frontend/lib/utils/text_markdown_spec.js
@@ -171,27 +171,40 @@ describe('init markdown', () => {
expect(textArea.value).toEqual(text.replace(selected, `[${selected}](url)`));
});
- it.each`
- key | expected
- ${'['} | ${`[${selected}]`}
- ${'*'} | ${`**${selected}**`}
- ${"'"} | ${`'${selected}'`}
- ${'_'} | ${`_${selected}_`}
- ${'`'} | ${`\`${selected}\``}
- ${'"'} | ${`"${selected}"`}
- ${'{'} | ${`{${selected}}`}
- ${'('} | ${`(${selected})`}
- ${'<'} | ${`<${selected}>`}
- `('generates $expected when $key is pressed', ({ key, expected }) => {
- const event = new KeyboardEvent('keydown', { key });
-
- textArea.addEventListener('keydown', keypressNoteText);
- textArea.dispatchEvent(event);
-
- expect(textArea.value).toEqual(text.replace(selected, expected));
+ describe('surrounds selected text with matching character', () => {
+ it.each`
+ key | expected
+ ${'['} | ${`[${selected}]`}
+ ${'*'} | ${`**${selected}**`}
+ ${"'"} | ${`'${selected}'`}
+ ${'_'} | ${`_${selected}_`}
+ ${'`'} | ${`\`${selected}\``}
+ ${'"'} | ${`"${selected}"`}
+ ${'{'} | ${`{${selected}}`}
+ ${'('} | ${`(${selected})`}
+ ${'<'} | ${`<${selected}>`}
+ `('generates $expected when $key is pressed', ({ key, expected }) => {
+ const event = new KeyboardEvent('keydown', { key });
+ gon.markdown_surround_selection = true;
+
+ textArea.addEventListener('keydown', keypressNoteText);
+ textArea.dispatchEvent(event);
+
+ expect(textArea.value).toEqual(text.replace(selected, expected));
+
+ // cursor placement should be after selection + 2 tag lengths
+ expect(textArea.selectionStart).toBe(selectedIndex + expected.length);
+ });
- // cursor placement should be after selection + 2 tag lengths
- expect(textArea.selectionStart).toBe(selectedIndex + expected.length);
+ it('does nothing if user preference disabled', () => {
+ const event = new KeyboardEvent('keydown', { key: '[' });
+ gon.markdown_surround_selection = false;
+
+ textArea.addEventListener('keydown', keypressNoteText);
+ textArea.dispatchEvent(event);
+
+ expect(textArea.value).toEqual(text);
+ });
});
describe('and text to be selected', () => {
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a84421f6d2c..f0981469123 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -41,6 +41,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:show_whitespace_in_diffs).to(:user_preference) }
it { is_expected.to delegate_method(:show_whitespace_in_diffs=).to(:user_preference).with_arguments(:args) }
+ it { is_expected.to delegate_method(:view_diffs_file_by_file).to(:user_preference) }
+ it { is_expected.to delegate_method(:view_diffs_file_by_file=).to(:user_preference).with_arguments(:args) }
+
it { is_expected.to delegate_method(:tab_width).to(:user_preference) }
it { is_expected.to delegate_method(:tab_width=).to(:user_preference).with_arguments(:args) }
@@ -59,6 +62,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:experience_level).to(:user_preference) }
it { is_expected.to delegate_method(:experience_level=).to(:user_preference).with_arguments(:args) }
+ it { is_expected.to delegate_method(:markdown_surround_selection).to(:user_preference) }
+ it { is_expected.to delegate_method(:markdown_surround_selection=).to(:user_preference).with_arguments(:args) }
+
it { is_expected.to delegate_method(:job_title).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:job_title=).to(:user_detail).with_arguments(:args).allow_nil }