BigW Consortium Gitlab

banner_spec.js 1.15 KB
Newer Older
1 2
import Vue from 'vue';
import banner from '~/cycle_analytics/components/banner.vue';
3
import mountComponent from 'spec/helpers/vue_mount_component_helper';
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

describe('Cycle analytics banner', () => {
  let vm;

  beforeEach(() => {
    const Component = Vue.extend(banner);
    vm = mountComponent(Component, {
      documentationLink: 'path',
    });
  });

  afterEach(() => {
    vm.$destroy();
  });

  it('should render cycle analytics information', () => {
    expect(
      vm.$el.querySelector('h4').textContent.trim(),
    ).toEqual('Introducing Cycle Analytics');
Filipa Lacerda committed
23

24
    expect(
Filipa Lacerda committed
25
      vm.$el.querySelector('p').textContent.trim().replace(/[\r\n]+/g, ' '),
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    ).toContain('Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.');
    expect(
      vm.$el.querySelector('a').textContent.trim(),
    ).toEqual('Read more');
    expect(
      vm.$el.querySelector('a').getAttribute('href'),
    ).toEqual('path');
  });

  it('should emit an event when close button is clicked', () => {
    spyOn(vm, '$emit');

    vm.$el.querySelector('.js-ca-dismiss-button').click();

    expect(vm.$emit).toHaveBeenCalled();
  });
});