diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-22 15:09:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-22 15:09:31 +0000 |
commit | 06d4ce7ee0c0f9cf84a6799d97f64dd710d6e9f6 (patch) | |
tree | 6c975e5931ee5655f2aa9dbb0c087604d513ec5a /spec/frontend | |
parent | cea25900b73fcb7029845eeca5e5a9170349f1dd (diff) | |
download | gitlab-ce-06d4ce7ee0c0f9cf84a6799d97f64dd710d6e9f6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/cycle_analytics/banner_spec.js | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/spec/frontend/cycle_analytics/banner_spec.js b/spec/frontend/cycle_analytics/banner_spec.js index 0cae0298cee..ef7998c5ff5 100644 --- a/spec/frontend/cycle_analytics/banner_spec.js +++ b/spec/frontend/cycle_analytics/banner_spec.js @@ -1,45 +1,47 @@ -import Vue from 'vue'; -import mountComponent from 'helpers/vue_mount_component_helper'; -import banner from '~/cycle_analytics/components/banner.vue'; +import { shallowMount } from '@vue/test-utils'; +import Banner from '~/cycle_analytics/components/banner.vue'; describe('Value Stream Analytics banner', () => { - let vm; + let wrapper; - beforeEach(() => { - const Component = Vue.extend(banner); - vm = mountComponent(Component, { - documentationLink: 'path', + const createComponent = () => { + wrapper = shallowMount(Banner, { + propsData: { + documentationLink: 'path', + }, }); + }; + + beforeEach(() => { + createComponent(); }); afterEach(() => { - vm.$destroy(); + wrapper.destroy(); }); it('should render value stream analytics information', () => { - expect(vm.$el.querySelector('h4').textContent.trim()).toEqual( - 'Introducing Value Stream Analytics', - ); + expect(wrapper.find('h4').text().trim()).toBe('Introducing Value Stream Analytics'); expect( - vm.$el - .querySelector('p') - .textContent.trim() + wrapper + .find('p') + .text() + .trim() .replace(/[\r\n]+/g, ' '), ).toContain( '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(vm.$el.querySelector('a').getAttribute('href')).toEqual('path'); + expect(wrapper.find('a').text().trim()).toBe('Read more'); + expect(wrapper.find('a').attributes('href')).toBe('path'); }); - it('should emit an event when close button is clicked', () => { - jest.spyOn(vm, '$emit').mockImplementation(() => {}); + it('should emit an event when close button is clicked', async () => { + 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(); }); }); |