gitlab-org--gitlab-foss/spec/javascripts/cycle_analytics/banner_spec.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
import banner from '~/cycle_analytics/components/banner.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
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', () => {
2018-10-17 03:13:26 -04:00
expect(vm.$el.querySelector('h4').textContent.trim()).toEqual('Introducing Cycle Analytics');
2018-01-09 06:58:34 -05:00
expect(
2018-10-17 03:13:26 -04:00
vm.$el
.querySelector('p')
.textContent.trim()
.replace(/[\r\n]+/g, ' '),
).toContain(
'Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.',
);
2018-10-09 14:03:09 -04:00
2018-10-17 03:13:26 -04:00
expect(vm.$el.querySelector('a').textContent.trim()).toEqual('Read more');
2018-10-09 14:03:09 -04:00
2018-10-17 03:13:26 -04:00
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();
});
});