Commit 338f5e2a authored by Kushal Pandya's avatar Kushal Pandya

Add `createLabelTitle` & `manageLabelsTitle` props for action string

parent 9d572c70
<script> <script>
import { __ } from '~/locale';
export default { export default {
props: { props: {
labelsWebUrl: { labelsWebUrl: {
type: String, type: String,
required: true, required: true,
}, },
createLabelTitle: {
type: String,
required: false,
default: () => __('Create new label'),
},
manageLabelsTitle: {
type: String,
required: false,
default: () => __('Manage labels'),
},
}, },
}; };
</script> </script>
...@@ -17,7 +29,7 @@ export default { ...@@ -17,7 +29,7 @@ export default {
href="#" href="#"
class="dropdown-toggle-page" class="dropdown-toggle-page"
> >
{{ __('Create new label') }} {{ createLabelTitle }}
</a> </a>
</li> </li>
<li> <li>
...@@ -26,7 +38,7 @@ export default { ...@@ -26,7 +38,7 @@ export default {
class="dropdown-external-link" class="dropdown-external-link"
:href="labelsWebUrl" :href="labelsWebUrl"
> >
{{ __('Manage labels') }} {{ manageLabelsTitle }}
</a> </a>
</li> </li>
</ul> </ul>
......
...@@ -6,15 +6,23 @@ import { mockConfig } from './mock_data'; ...@@ -6,15 +6,23 @@ import { mockConfig } from './mock_data';
import mountComponent from '../../../../helpers/vue_mount_component_helper'; import mountComponent from '../../../../helpers/vue_mount_component_helper';
const createComponent = (labelsWebUrl = mockConfig.labelsWebUrl) => { const createComponent = (
labelsWebUrl = mockConfig.labelsWebUrl,
createLabelTitle,
manageLabelsTitle,
) => {
const Component = Vue.extend(dropdownFooterComponent); const Component = Vue.extend(dropdownFooterComponent);
return mountComponent(Component, { return mountComponent(Component, {
labelsWebUrl, labelsWebUrl,
createLabelTitle,
manageLabelsTitle,
}); });
}; };
describe('DropdownFooterComponent', () => { describe('DropdownFooterComponent', () => {
const createLabelTitle = 'Create project label';
const manageLabelsTitle = 'Manage project labels';
let vm; let vm;
beforeEach(() => { beforeEach(() => {
...@@ -26,17 +34,35 @@ describe('DropdownFooterComponent', () => { ...@@ -26,17 +34,35 @@ describe('DropdownFooterComponent', () => {
}); });
describe('template', () => { describe('template', () => {
it('renders `Create new label` link element', () => { it('renders link element with `Create new label` when `createLabelTitle` prop is not provided', () => {
const createLabelEl = vm.$el.querySelector('.dropdown-footer-list .dropdown-toggle-page'); const createLabelEl = vm.$el.querySelector('.dropdown-footer-list .dropdown-toggle-page');
expect(createLabelEl).not.toBeNull(); expect(createLabelEl).not.toBeNull();
expect(createLabelEl.innerText.trim()).toBe('Create new label'); expect(createLabelEl.innerText.trim()).toBe('Create new label');
}); });
it('renders `Manage labels` link element', () => { it('renders link element with value of `createLabelTitle` prop', () => {
const vmWithCreateLabelTitle = createComponent(mockConfig.labelsWebUrl, createLabelTitle);
const createLabelEl = vmWithCreateLabelTitle.$el.querySelector('.dropdown-footer-list .dropdown-toggle-page');
expect(createLabelEl.innerText.trim()).toBe(createLabelTitle);
vmWithCreateLabelTitle.$destroy();
});
it('renders link element with `Manage labels` when `manageLabelsTitle` prop is not provided', () => {
const manageLabelsEl = vm.$el.querySelector('.dropdown-footer-list .dropdown-external-link'); const manageLabelsEl = vm.$el.querySelector('.dropdown-footer-list .dropdown-external-link');
expect(manageLabelsEl).not.toBeNull(); expect(manageLabelsEl).not.toBeNull();
expect(manageLabelsEl.getAttribute('href')).toBe(vm.labelsWebUrl); expect(manageLabelsEl.getAttribute('href')).toBe(vm.labelsWebUrl);
expect(manageLabelsEl.innerText.trim()).toBe('Manage labels'); expect(manageLabelsEl.innerText.trim()).toBe('Manage labels');
}); });
it('renders link element with value of `manageLabelsTitle` prop', () => {
const vmWithManageLabelsTitle = createComponent(
mockConfig.labelsWebUrl,
createLabelTitle,
manageLabelsTitle,
);
const manageLabelsEl = vmWithManageLabelsTitle.$el.querySelector('.dropdown-footer-list .dropdown-external-link');
expect(manageLabelsEl.innerText.trim()).toBe(manageLabelsTitle);
vmWithManageLabelsTitle.$destroy();
});
}); });
}); });
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