Commit f296c491 authored by pburdette's avatar pburdette

Apply reviewer feedback

Add datatest-id and use
logical OR operator.
parent 0d16e67e
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
: null; : null;
}, },
refUrl() { refUrl() {
return this.commitRef.ref_url ?? this.commitRef.path; return this.commitRef.ref_url || this.commitRef.path;
}, },
}, },
}; };
...@@ -156,9 +156,15 @@ export default { ...@@ -156,9 +156,15 @@ export default {
class="ref-name" class="ref-name"
>{{ mergeRequestRef.iid }}</gl-link >{{ mergeRequestRef.iid }}</gl-link
> >
<gl-link v-else v-gl-tooltip :href="refUrl" :title="commitRef.name" class="ref-name">{{ <gl-link
commitRef.name v-else
}}</gl-link> v-gl-tooltip
:href="refUrl"
:title="commitRef.name"
class="ref-name"
data-testid="ref-name"
>{{ commitRef.name }}</gl-link
>
</template> </template>
<gl-icon name="commit" class="commit-icon js-commit-icon" /> <gl-icon name="commit" class="commit-icon js-commit-icon" />
......
...@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import CommitComponent from '~/vue_shared/components/commit.vue'; import CommitComponent from '~/vue_shared/components/commit.vue';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue'; import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
describe('Commit component', () => { describe('Commit component', () => {
let props; let props;
...@@ -13,11 +14,14 @@ describe('Commit component', () => { ...@@ -13,11 +14,14 @@ describe('Commit component', () => {
}; };
const findUserAvatar = () => wrapper.find(UserAvatarLink); const findUserAvatar = () => wrapper.find(UserAvatarLink);
const findRefName = () => wrapper.findByTestId('ref-name');
const createComponent = (propsData) => { const createComponent = (propsData) => {
wrapper = shallowMount(CommitComponent, { wrapper = extendedWrapper(
shallowMount(CommitComponent, {
propsData, propsData,
}); }),
);
}; };
afterEach(() => { afterEach(() => {
...@@ -235,8 +239,8 @@ describe('Commit component', () => { ...@@ -235,8 +239,8 @@ describe('Commit component', () => {
createComponent(props); createComponent(props);
expect(wrapper.find('.ref-name').exists()).toBe(true); expect(findRefName().exists()).toBe(true);
expect(wrapper.find('.ref-name').attributes('href')).toBe(props.commitRef.path); expect(findRefName().attributes('href')).toBe(props.commitRef.path);
}); });
}); });
}); });
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