Commit e999b6a8 authored by David O'Regan's avatar David O'Regan

Merge branch 'vs-migrate-cycle-analytics-to-vtu' into 'master'

Migrate cycle-analytics/banner_spec to VTU

See merge request gitlab-org/gitlab!57024
parents 794618a9 479c8216
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import mountComponent from 'helpers/vue_mount_component_helper'; import Banner from '~/cycle_analytics/components/banner.vue';
import banner from '~/cycle_analytics/components/banner.vue';
describe('Value Stream Analytics banner', () => { describe('Value Stream Analytics banner', () => {
let vm; let wrapper;
beforeEach(() => { const createComponent = () => {
const Component = Vue.extend(banner); wrapper = shallowMount(Banner, {
vm = mountComponent(Component, { propsData: {
documentationLink: 'path', documentationLink: 'path',
},
}); });
};
beforeEach(() => {
createComponent();
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('should render value stream analytics information', () => { it('should render value stream analytics information', () => {
expect(vm.$el.querySelector('h4').textContent.trim()).toEqual( expect(wrapper.find('h4').text().trim()).toBe('Introducing Value Stream Analytics');
'Introducing Value Stream Analytics',
);
expect( expect(
vm.$el wrapper
.querySelector('p') .find('p')
.textContent.trim() .text()
.trim()
.replace(/[\r\n]+/g, ' '), .replace(/[\r\n]+/g, ' '),
).toContain( ).toContain(
'Value Stream Analytics gives an overview of how much time it takes to go from idea to production in your project.', 'Value Stream 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(wrapper.find('a').text().trim()).toBe('Read more');
expect(wrapper.find('a').attributes('href')).toBe('path');
expect(vm.$el.querySelector('a').getAttribute('href')).toEqual('path');
}); });
it('should emit an event when close button is clicked', () => { it('should emit an event when close button is clicked', async () => {
jest.spyOn(vm, '$emit').mockImplementation(() => {}); jest.spyOn(wrapper.vm, '$emit').mockImplementation(() => {});
vm.$el.querySelector('.js-ca-dismiss-button').click(); await wrapper.find('.js-ca-dismiss-button').trigger('click');
expect(vm.$emit).toHaveBeenCalled(); expect(wrapper.vm.$emit).toHaveBeenCalled();
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment