debian-mirror-gitlab/spec/frontend/cycle_analytics/banner_spec.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
import { shallowMount } from '@vue/test-utils';
import Banner from '~/cycle_analytics/components/banner.vue';
2018-03-17 18:26:18 +05:30
2021-02-22 17:27:13 +05:30
describe('Value Stream Analytics banner', () => {
2021-04-29 21:17:54 +05:30
let wrapper;
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
const createComponent = () => {
wrapper = shallowMount(Banner, {
propsData: {
documentationLink: 'path',
},
2018-03-17 18:26:18 +05:30
});
2021-04-29 21:17:54 +05:30
};
beforeEach(() => {
createComponent();
2018-03-17 18:26:18 +05:30
});
afterEach(() => {
2021-04-29 21:17:54 +05:30
wrapper.destroy();
2018-03-17 18:26:18 +05:30
});
2020-03-13 15:44:24 +05:30
it('should render value stream analytics information', () => {
2021-04-29 21:17:54 +05:30
expect(wrapper.find('h4').text().trim()).toBe('Introducing Value Stream Analytics');
2018-03-17 18:26:18 +05:30
expect(
2021-04-29 21:17:54 +05:30
wrapper
.find('p')
.text()
.trim()
2018-12-13 13:39:08 +05:30
.replace(/[\r\n]+/g, ' '),
).toContain(
2020-03-13 15:44:24 +05:30
'Value Stream Analytics gives an overview of how much time it takes to go from idea to production in your project.',
2018-12-13 13:39:08 +05:30
);
2021-04-29 21:17:54 +05:30
expect(wrapper.find('a').text().trim()).toBe('Read more');
expect(wrapper.find('a').attributes('href')).toBe('path');
2018-03-17 18:26:18 +05:30
});
2021-04-29 21:17:54 +05:30
it('should emit an event when close button is clicked', async () => {
jest.spyOn(wrapper.vm, '$emit').mockImplementation(() => {});
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
await wrapper.find('.js-ca-dismiss-button').trigger('click');
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
expect(wrapper.vm.$emit).toHaveBeenCalled();
2018-03-17 18:26:18 +05:30
});
});