2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
2018-03-27 19:54:05 +05:30
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('clipboard button', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
const Component = Vue.extend(clipboardButton);
|
2018-03-17 18:26:18 +05:30
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
text: 'copy me',
|
|
|
|
title: 'Copy this value into Clipboard!',
|
2018-03-27 19:54:05 +05:30
|
|
|
cssClass: 'btn-danger',
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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.querySelector('i').className).toEqual('fa fa-clipboard');
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
it('should render provided classname', () => {
|
|
|
|
expect(vm.$el.classList).toContain('btn-danger');
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|