Commit 3ac22d0c authored by Nathan Friend's avatar Nathan Friend

Allow ref selector to receive parent attrs

This commit updates the ref selector dropdown component to allow its
parent to bind attributes to the root element of this component.
parent ad596914
...@@ -107,7 +107,7 @@ export default { ...@@ -107,7 +107,7 @@ export default {
</script> </script>
<template> <template>
<gl-new-dropdown class="ref-selector" @shown="focusSearchBox"> <gl-new-dropdown v-bind="$attrs" class="ref-selector" @shown="focusSearchBox">
<template slot="button-content"> <template slot="button-content">
<span class="gl-flex-grow-1 gl-ml-2 gl-text-gray-600" data-testid="button-content"> <span class="gl-flex-grow-1 gl-ml-2 gl-text-gray-600" data-testid="button-content">
<span v-if="selectedRef" class="gl-font-monospace">{{ selectedRef }}</span> <span v-if="selectedRef" class="gl-font-monospace">{{ selectedRef }}</span>
......
...@@ -26,13 +26,14 @@ describe('Ref selector component', () => { ...@@ -26,13 +26,14 @@ describe('Ref selector component', () => {
let tagsApiCallSpy; let tagsApiCallSpy;
let commitApiCallSpy; let commitApiCallSpy;
const createComponent = (props = {}) => { const createComponent = (props = {}, attrs = {}) => {
wrapper = mount(RefSelector, { wrapper = mount(RefSelector, {
propsData: { propsData: {
projectId, projectId,
value: '', value: '',
...props, ...props,
}, },
attrs,
listeners: { listeners: {
// simulate a parent component v-model binding // simulate a parent component v-model binding
input: selectedRef => { input: selectedRef => {
...@@ -164,6 +165,20 @@ describe('Ref selector component', () => { ...@@ -164,6 +165,20 @@ describe('Ref selector component', () => {
}); });
describe('post-initialization behavior', () => { describe('post-initialization behavior', () => {
describe('when the parent component provides an `id` binding', () => {
const id = 'git-ref';
beforeEach(() => {
createComponent({}, { id });
return waitForRequests();
});
it('adds the provided ID to the GlNewDropdown instance', () => {
expect(wrapper.attributes().id).toBe(id);
});
});
describe('when a ref is pre-selected', () => { describe('when a ref is pre-selected', () => {
const preselectedRef = fixtures.branches[0].name; const preselectedRef = fixtures.branches[0].name;
......
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