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:
authorFilipa Lacerda <filipa@gitlab.com>2018-07-30 16:37:28 +0300
committerPhil Hughes <me@iamphill.com>2018-07-30 16:37:28 +0300
commit202e37bbaf2c367e9963d0cc292aafd5fa6c5dfe (patch)
tree3064797caea578826a8b917b258bf1f11161a05e /spec/javascripts
parent036c6db81362e3eff84eefcdb8c1e72bb79ab77c (diff)
Resolve "Copy diff file path as GFM" is broken
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/diffs/components/diff_file_header_spec.js2
-rw-r--r--spec/javascripts/vue_shared/components/clipboard_button_spec.js54
2 files changed, 36 insertions, 20 deletions
diff --git a/spec/javascripts/diffs/components/diff_file_header_spec.js b/spec/javascripts/diffs/components/diff_file_header_spec.js
index 241ff07026e..860a976e7cd 100644
--- a/spec/javascripts/diffs/components/diff_file_header_spec.js
+++ b/spec/javascripts/diffs/components/diff_file_header_spec.js
@@ -303,7 +303,7 @@ describe('diff_file_header', () => {
const button = vm.$el.querySelector('.btn-clipboard');
expect(button).not.toBe(null);
- expect(button.dataset.clipboardText).toBe(props.diffFile.filePath);
+ expect(button.dataset.clipboardText).toBe('{"text":"files/ruby/popen.rb","gfm":"`files/ruby/popen.rb`"}');
});
describe('file mode', () => {
diff --git a/spec/javascripts/vue_shared/components/clipboard_button_spec.js b/spec/javascripts/vue_shared/components/clipboard_button_spec.js
index e135690349e..ea525b1e44f 100644
--- a/spec/javascripts/vue_shared/components/clipboard_button_spec.js
+++ b/spec/javascripts/vue_shared/components/clipboard_button_spec.js
@@ -6,31 +6,47 @@ describe('clipboard button', () => {
const Component = Vue.extend(clipboardButton);
let vm;
- beforeEach(() => {
- vm = mountComponent(Component, {
- text: 'copy me',
- title: 'Copy this value into Clipboard!',
- cssClass: 'btn-danger',
- });
- });
-
afterEach(() => {
vm.$destroy();
});
- it('renders a button for clipboard', () => {
- expect(vm.$el.tagName).toEqual('BUTTON');
- expect(vm.$el.getAttribute('data-clipboard-text')).toEqual('copy me');
- expect(vm.$el).toHaveSpriteIcon('duplicate');
- });
+ describe('without gfm', () => {
+ beforeEach(() => {
+ vm = mountComponent(Component, {
+ text: 'copy me',
+ title: 'Copy this value into Clipboard!',
+ cssClass: 'btn-danger',
+ });
+ });
- it('should have a tooltip with default values', () => {
- expect(vm.$el.getAttribute('data-original-title')).toEqual('Copy this value into Clipboard!');
- expect(vm.$el.getAttribute('data-placement')).toEqual('top');
- expect(vm.$el.getAttribute('data-container')).toEqual(null);
+ it('renders a button for clipboard', () => {
+ expect(vm.$el.tagName).toEqual('BUTTON');
+ expect(vm.$el.getAttribute('data-clipboard-text')).toEqual('copy me');
+ expect(vm.$el).toHaveSpriteIcon('duplicate');
+ });
+
+ it('should have a tooltip with default values', () => {
+ expect(vm.$el.getAttribute('data-original-title')).toEqual('Copy this value into Clipboard!');
+ expect(vm.$el.getAttribute('data-placement')).toEqual('top');
+ expect(vm.$el.getAttribute('data-container')).toEqual(null);
+ });
+
+ it('should render provided classname', () => {
+ expect(vm.$el.classList).toContain('btn-danger');
+ });
});
- it('should render provided classname', () => {
- expect(vm.$el.classList).toContain('btn-danger');
+ describe('with gfm', () => {
+ it('sets data-clipboard-text with gfm', () => {
+ vm = mountComponent(Component, {
+ text: 'copy me',
+ gfm: '`path/to/file`',
+ title: 'Copy this value into Clipboard!',
+ cssClass: 'btn-danger',
+ });
+ expect(vm.$el.getAttribute('data-clipboard-text')).toEqual(
+ '{"text":"copy me","gfm":"`path/to/file`"}',
+ );
+ });
});
});