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