diff --git a/lib/form/html.js b/lib/form/html.js index ef99ca8..83ff437 100644 --- a/lib/form/html.js +++ b/lib/form/html.js @@ -90,7 +90,7 @@ const addRequired = (html, input, index) => { if (input.required === 'save' || inp.required === 'save' || input.required === 'publish' || inp.required === 'publish') { let level = ''; - const required = input.required && inp.required; + const required = inp.required || input.required; if (inp.required !== undefined) { level += `required--${inp.required}`; } diff --git a/tests/html.js b/tests/html.js index bbfa1d9..f9a8a00 100644 --- a/tests/html.js +++ b/tests/html.js @@ -131,3 +131,65 @@ test('Add Required Checkbox - Pass', t => { const result = html.required(param.html, param.input, param.index); t.false(includes(result, expected)); }); + +test('Add Required and Repeatable - Pass', t => { + const param = { + html: '"
"', + input: { + description: 'I am the Bar Content Type Config text description', + html: '', + id: 'text-required', + inputs: { + text: { + id: '91f79620-ba21-4a4a-a4c7-02f456129b0f--1', + label: 'Add Your Text', + name: 'name--text', + placeholder: 'Text goes here', + type: 'text', + }, + }, + name: 'Add Your Text', + required: 'publish', + repeatable: 'true', + type: 'text', + }, + index: undefined, + }; + const expected = 'aria-required="true" required'; + const result = html.required(param.html, param.input, param.index); + t.false(includes(result, expected)); +}); + +test('Add Object Required - Pass', t => { + const param = { + html: '""', + input: { + name: 'Object', + description: 'I am the Foo Object text description', + html: '', + id: 'object-required', + inputs: { + text: { + id: '91f79620-ba21-4a4a-a4c7-02f456129b0f--1', + label: 'Add Your Text', + name: 'name--text', + placeholder: 'Text goes here', + type: 'text', + required: 'publish', + }, + url: { + id: '91f79620-ba21-4a4a-a4c7-02f456129b0f--2', + label: 'Add Your URL', + name: 'name--url', + placeholder: 'http://', + type: 'url', + required: 'publish', + }, + }, + }, + index: undefined, + }; + const expected = 'aria-required="true" required'; + const result = html.required(param.html, param.input, param.index); + t.false(includes(result, expected)); +});