summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_shared/components/clipboard_button_spec.js
blob: f598b1afa745d1401ad9e7fa1e0f6b992f21c85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Vue from 'vue';
import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

describe('clipboard button', () => {
  let vm;

  beforeEach(() => {
    const Component = Vue.extend(clipboardButton);
    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.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);
  });

  it('should render provided classname', () => {
    expect(vm.$el.classList).toContain('btn-danger');
  });
});