diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/clipboard_button_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/clipboard_button_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/clipboard_button_spec.js b/spec/frontend/vue_shared/components/clipboard_button_spec.js index ac0be1537b7..0d4266ce82f 100644 --- a/spec/frontend/vue_shared/components/clipboard_button_spec.js +++ b/spec/frontend/vue_shared/components/clipboard_button_spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils'; import { GlButton } from '@gitlab/ui'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; +import initCopyToClipboard from '~/behaviors/copy_to_clipboard'; describe('clipboard button', () => { let wrapper; @@ -87,4 +88,25 @@ describe('clipboard button', () => { expect(onClick).toHaveBeenCalled(); }); + + describe('integration', () => { + it('actually copies to clipboard', () => { + initCopyToClipboard(); + + document.execCommand = () => {}; + jest.spyOn(document, 'execCommand').mockImplementation(() => true); + + createWrapper( + { + text: 'copy me', + title: 'Copy this value', + }, + { attachTo: document.body }, + ); + + findButton().trigger('click'); + + expect(document.execCommand).toHaveBeenCalledWith('copy'); + }); + }); }); |