Commit fa487fcf authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'nfriend-allow-ref-selector-id-binding' into 'master'

Allow ref selector component to receive parent attributes

See merge request gitlab-org/gitlab!38401
parents f0adb9d5 3ac22d0c
......@@ -107,7 +107,7 @@ export default {
</script>
<template>
<gl-new-dropdown class="ref-selector" @shown="focusSearchBox">
<gl-new-dropdown v-bind="$attrs" class="ref-selector" @shown="focusSearchBox">
<template slot="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>
......
......@@ -26,13 +26,14 @@ describe('Ref selector component', () => {
let tagsApiCallSpy;
let commitApiCallSpy;
const createComponent = (props = {}) => {
const createComponent = (props = {}, attrs = {}) => {
wrapper = mount(RefSelector, {
propsData: {
projectId,
value: '',
...props,
},
attrs,
listeners: {
// simulate a parent component v-model binding
input: selectedRef => {
......@@ -164,6 +165,20 @@ describe('Ref selector component', () => {
});
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', () => {
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