diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/frontend/environments/commit_spec.js | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/frontend/environments/commit_spec.js')
-rw-r--r-- | spec/frontend/environments/commit_spec.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/frontend/environments/commit_spec.js b/spec/frontend/environments/commit_spec.js new file mode 100644 index 00000000000..32eb4b77528 --- /dev/null +++ b/spec/frontend/environments/commit_spec.js @@ -0,0 +1,71 @@ +import { mountExtended } from 'helpers/vue_test_utils_helper'; +import Commit from '~/environments/components/commit.vue'; +import { resolvedEnvironment } from './graphql/mock_data'; + +describe('~/environments/components/commit.vue', () => { + let commit; + let wrapper; + + beforeEach(() => { + commit = resolvedEnvironment.lastDeployment.commit; + }); + + const createWrapper = ({ propsData = {} } = {}) => + mountExtended(Commit, { + propsData: { + commit, + ...propsData, + }, + }); + + afterEach(() => { + wrapper?.destroy(); + }); + + describe('with gitlab user', () => { + beforeEach(() => { + wrapper = createWrapper(); + }); + + it('links to the user profile', () => { + const link = wrapper.findByRole('link', { name: commit.author.name }); + expect(link.attributes('href')).toBe(commit.author.path); + }); + + it('displays the user avatar', () => { + const avatar = wrapper.findByRole('img', { name: 'avatar' }); + expect(avatar.attributes('src')).toBe(commit.author.avatarUrl); + }); + + it('links the commit message to the commit', () => { + const message = wrapper.findByRole('link', { name: commit.message }); + + expect(message.attributes('href')).toBe(commit.commitPath); + }); + }); + describe('without gitlab user', () => { + beforeEach(() => { + commit = { + ...commit, + author: null, + }; + wrapper = createWrapper(); + }); + + it('links to the user profile', () => { + const link = wrapper.findByRole('link', { name: commit.authorName }); + expect(link.attributes('href')).toBe(`mailto:${commit.authorEmail}`); + }); + + it('displays the user avatar', () => { + const avatar = wrapper.findByRole('img', { name: 'avatar' }); + expect(avatar.attributes('src')).toBe(commit.authorGravatarUrl); + }); + + it('displays the commit message', () => { + const message = wrapper.findByRole('link', { name: commit.message }); + + expect(message.attributes('href')).toBe(commit.commitPath); + }); + }); +}); |