Commit f65cbc2a authored by Jacques's avatar Jacques

Address code review comments

Addressed maintainer review comments
parent f8f0676a
...@@ -23,8 +23,10 @@ export default { ...@@ -23,8 +23,10 @@ export default {
</script> </script>
<template> <template>
<div class="file-fork-suggestion"> <div
<span class="file-fork-suggestion-note" data-testid="message">{{ $options.i18n.message }}</span> class="gl-display-flex gl-justify-content-end gl-align-items-center gl-bg-gray-10 gl-px-5 gl-py-2 gl-border-1 gl-border-b-solid gl-border-gray-100"
>
<span class="gl-mr-6" data-testid="message">{{ $options.i18n.message }}</span>
<gl-button <gl-button
class="gl-mr-3" class="gl-mr-3"
...@@ -36,7 +38,7 @@ export default { ...@@ -36,7 +38,7 @@ export default {
{{ $options.i18n.fork }} {{ $options.i18n.fork }}
</gl-button> </gl-button>
<gl-button class="gl-mr-3" data-testid="cancel" @click="$emit('cancel')"> <gl-button data-testid="cancel" @click="$emit('cancel')">
{{ $options.i18n.cancel }} {{ $options.i18n.cancel }}
</gl-button> </gl-button>
</div> </div>
......
import { shallowMount } from '@vue/test-utils'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ForkSuggestion from '~/repository/components/fork_suggestion.vue'; import ForkSuggestion from '~/repository/components/fork_suggestion.vue';
const DEFAULT_PROPS = { forkPath: 'some_file.js/fork' }; const DEFAULT_PROPS = { forkPath: 'some_file.js/fork' };
...@@ -7,7 +7,7 @@ describe('ForkSuggestion component', () => { ...@@ -7,7 +7,7 @@ describe('ForkSuggestion component', () => {
let wrapper; let wrapper;
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(ForkSuggestion, { wrapper = shallowMountExtended(ForkSuggestion, {
propsData: { ...DEFAULT_PROPS }, propsData: { ...DEFAULT_PROPS },
}); });
}; };
...@@ -16,32 +16,24 @@ describe('ForkSuggestion component', () => { ...@@ -16,32 +16,24 @@ describe('ForkSuggestion component', () => {
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
const findMessage = () => wrapper.find('[data-testid="message"]'); const { i18n } = ForkSuggestion;
const findForkButton = () => wrapper.find('[data-testid="fork"]'); const findMessage = () => wrapper.findByTestId('message');
const findCancelButton = () => wrapper.find('[data-testid="cancel"]'); const findForkButton = () => wrapper.findByTestId('fork');
const findCancelButton = () => wrapper.findByTestId('cancel');
it('renders a message', () => { it('renders a message', () => {
expect(findMessage().exists()).toBe(true); expect(findMessage().text()).toBe(i18n.message);
expect(findMessage().text()).toBe(
'You can’t edit files directly in this project. Fork this project and submit a merge request with your changes.',
);
});
it('renders component', () => {
const { forkPath } = DEFAULT_PROPS;
expect(wrapper.props()).toMatchObject({ forkPath });
}); });
it('renders a Fork button', () => { it('renders a Fork button', () => {
expect(findForkButton().exists()).toBe(true); const forkButton = findForkButton();
expect(findForkButton().text()).toBe('Fork');
expect(findForkButton().attributes('href')).toBe(DEFAULT_PROPS.forkPath); expect(forkButton.text()).toBe(i18n.fork);
expect(forkButton.attributes('href')).toBe(DEFAULT_PROPS.forkPath);
}); });
it('renders a Cancel button', () => { it('renders a Cancel button', () => {
expect(findCancelButton().exists()).toBe(true); expect(findCancelButton().text()).toBe(i18n.cancel);
expect(findCancelButton().text()).toBe('Cancel');
}); });
it('emits a cancel event when Cancel button is clicked', () => { it('emits a cancel event when Cancel button is clicked', () => {
......
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