Commit 0b9ff82f authored by Fernando's avatar Fernando

Apply maintainer patch

* Patch reworks the disabled prop check by checking
attribute on fieldset element
parent 38e8e2b7
import { shallowMount } from '@vue/test-utils';
import { shallowMount, mount } from '@vue/test-utils';
import DynamicFields from 'ee/security_configuration/sast/components/dynamic_fields.vue';
import { makeEntities } from './helpers';
describe('DynamicFields component', () => {
let wrapper;
const createComponent = (props = {}) => {
wrapper = shallowMount(DynamicFields, {
const createComponent = (props = {}, mountFn = shallowMount) => {
wrapper = mountFn(DynamicFields, {
propsData: {
...props,
},
......@@ -34,6 +34,21 @@ describe('DynamicFields component', () => {
});
});
describe.each([true, false])('given the disabled prop is %p', disabled => {
beforeEach(() => {
createComponent({ entities: [], disabled }, mount);
});
it('uses a fieldset as the root element', () => {
expect(wrapper.element.tagName).toBe('FIELDSET');
});
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset#attr-disabled
it(`${disabled ? 'sets' : 'does not set'} the disabled attribute on the root element`, () => {
expect('disabled' in wrapper.attributes()).toBe(disabled);
});
});
describe('given valid entities', () => {
let entities;
let fields;
......@@ -44,17 +59,6 @@ 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