Commit 38e8e2b7 authored by Fernando's avatar Fernando

Add disabled prop to dynamic fields

* Update unit tests
parent 6aa21d72
......@@ -18,6 +18,11 @@ export default {
required: true,
validator: value => value.every(isValidConfigurationEntity),
},
disabled: {
type: Boolean,
required: false,
default: false,
},
},
methods: {
componentForEntity({ type }) {
......@@ -49,7 +54,7 @@ export default {
</script>
<template>
<gl-form-group>
<gl-form-group :disabled="disabled">
<component
:is="componentForEntity(entity)"
v-for="entity in entities"
......
......@@ -116,7 +116,7 @@ describe('AnalyzerConfiguration component', () => {
});
it('passes the disabled prop to dynamic fields component', () => {
expect(findDynamicFields().vm.$attrs.disabled).toBe(!analyzerEntity.enabled);
expect(findDynamicFields().props('disabled')).toBe(!analyzerEntity.enabled);
});
it('passes the entities prop to the dynamic fields component', () => {
......
......@@ -44,6 +44,17 @@ describe('DynamicFields component', () => {
fields = findFields();
});
describe.each([true, false])('when the disabled prop is %s', disabled => {
beforeEach(() => {
entities = makeEntities(3);
createComponent({ entities, disabled });
});
it(`it is passed a disabled prop set to ${disabled}`, () => {
expect(wrapper.props('disabled')).toBe(disabled);
});
});
it('renders each field with the correct component', () => {
entities.forEach((entity, i) => {
const field = fields.at(i);
......
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