summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_shared/components/sidebar/collapsed_calendar_icon_spec.js
blob: 6bff152169550e13509d490eeadca30ff439b5d7 (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 collapsedCalendarIcon from '~/vue_shared/components/sidebar/collapsed_calendar_icon.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

describe('collapsedCalendarIcon', () => {
  let vm;
  beforeEach(() => {
    const CollapsedCalendarIcon = Vue.extend(collapsedCalendarIcon);
    vm = mountComponent(CollapsedCalendarIcon, {
      containerClass: 'test-class',
      text: 'text',
      showIcon: false,
    });
  });

  it('should add class to container', () => {
    expect(vm.$el.classList.contains('test-class')).toEqual(true);
  });

  it('should hide calendar icon if showIcon', () => {
    expect(vm.$el.querySelector('.fa-calendar')).toBeNull();
  });

  it('should render text', () => {
    expect(vm.$el.querySelector('span').innerText.trim()).toEqual('text');
  });

  it('should emit click event when container is clicked', () => {
    const click = jasmine.createSpy();
    vm.$on('click', click);

    vm.$el.click();

    expect(click).toHaveBeenCalled();
  });
});