diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 15:06:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 15:06:45 +0300 |
commit | bffcdf9bca11a4d43cc40e3f382f03088d36f7c6 (patch) | |
tree | c773436393b7a59b5f6b14388b9fa6402a9bd198 /spec/frontend/pipelines/pipeline_triggerer_spec.js | |
parent | 259c0cc0c4f8a49001b33d1bee577f4422e16d62 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines/pipeline_triggerer_spec.js')
-rw-r--r-- | spec/frontend/pipelines/pipeline_triggerer_spec.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/spec/frontend/pipelines/pipeline_triggerer_spec.js b/spec/frontend/pipelines/pipeline_triggerer_spec.js index 45ac278dd38..e211852f74b 100644 --- a/spec/frontend/pipelines/pipeline_triggerer_spec.js +++ b/spec/frontend/pipelines/pipeline_triggerer_spec.js @@ -1,9 +1,16 @@ -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue'; import pipelineTriggerer from '~/pipelines/components/pipeline_triggerer.vue'; describe('Pipelines Triggerer', () => { let wrapper; + const expectComponentWithProps = (Component, props = {}) => { + const componentWrapper = wrapper.find(Component); + expect(componentWrapper.isVisible()).toBe(true); + expect(componentWrapper.props()).toEqual(expect.objectContaining(props)); + }; + const mockData = { pipeline: { user: { @@ -15,9 +22,10 @@ describe('Pipelines Triggerer', () => { }; const createComponent = () => { - wrapper = mount(pipelineTriggerer, { + wrapper = shallowMount(pipelineTriggerer, { propsData: mockData, sync: false, + attachToDocument: true, }); }; @@ -33,14 +41,12 @@ describe('Pipelines Triggerer', () => { expect(wrapper.contains('.table-section')).toBe(true); }); - it('should render triggerer information when triggerer is provided', () => { - const link = wrapper.find('.js-pipeline-url-user'); - - expect(link.attributes('href')).toEqual(mockData.pipeline.user.path); - expect(link.find('.js-user-avatar-image-toolip').text()).toEqual(mockData.pipeline.user.name); - expect(link.find('img.avatar').attributes('src')).toEqual( - `${mockData.pipeline.user.avatar_url}?width=26`, - ); + it('should pass triggerer information when triggerer is provided', () => { + expectComponentWithProps(UserAvatarLink, { + linkHref: mockData.pipeline.user.path, + tooltipText: mockData.pipeline.user.name, + imgSrc: mockData.pipeline.user.avatar_url, + }); }); it('should render "API" when no triggerer is provided', () => { @@ -50,7 +56,7 @@ describe('Pipelines Triggerer', () => { }, }); - wrapper.vm.$nextTick(() => { + return wrapper.vm.$nextTick(() => { expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API'); }); }); |