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:
Diffstat (limited to 'spec/frontend/vue_shared/components/clipboard_button_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/clipboard_button_spec.js42
1 files changed, 38 insertions, 4 deletions
diff --git a/spec/frontend/vue_shared/components/clipboard_button_spec.js b/spec/frontend/vue_shared/components/clipboard_button_spec.js
index 51a2653befc..ac0be1537b7 100644
--- a/spec/frontend/vue_shared/components/clipboard_button_spec.js
+++ b/spec/frontend/vue_shared/components/clipboard_button_spec.js
@@ -1,16 +1,19 @@
-import { shallowMount } from '@vue/test-utils';
+import { mount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
describe('clipboard button', () => {
let wrapper;
- const createWrapper = propsData => {
- wrapper = shallowMount(ClipboardButton, {
+ const createWrapper = (propsData, options = {}) => {
+ wrapper = mount(ClipboardButton, {
propsData,
+ ...options,
});
};
+ const findButton = () => wrapper.find(GlButton);
+
afterEach(() => {
wrapper.destroy();
wrapper = null;
@@ -26,7 +29,7 @@ describe('clipboard button', () => {
});
it('renders a button for clipboard', () => {
- expect(wrapper.find(GlButton).exists()).toBe(true);
+ expect(findButton().exists()).toBe(true);
expect(wrapper.attributes('data-clipboard-text')).toBe('copy me');
});
@@ -53,4 +56,35 @@ describe('clipboard button', () => {
);
});
});
+
+ it('renders default slot as button text', () => {
+ createWrapper(
+ {
+ text: 'copy me',
+ title: 'Copy this value',
+ },
+ {
+ slots: {
+ default: 'Foo bar',
+ },
+ },
+ );
+
+ expect(findButton().text()).toBe('Foo bar');
+ });
+
+ it('re-emits button events', () => {
+ const onClick = jest.fn();
+ createWrapper(
+ {
+ text: 'copy me',
+ title: 'Copy this value',
+ },
+ { listeners: { click: onClick } },
+ );
+
+ findButton().trigger('click');
+
+ expect(onClick).toHaveBeenCalled();
+ });
});