diff --git a/lib/content-types/merge.js b/lib/content-types/merge.js index 6fd662b..4d2d1fb 100644 --- a/lib/content-types/merge.js +++ b/lib/content-types/merge.js @@ -130,6 +130,11 @@ const squish = (types) => { merged.script = plugin.inputs[attr].script; } + // Options of attribute overrides default + if (attribute.inputs[attr].hasOwnProperty('options')) { + merged.options = attribute.inputs[attr].options; + } + // add required if it doesn't exist if (!merged.hasOwnProperty('required')) { merged.required = plugin.required; diff --git a/package.json b/package.json index f51b589..7a8b1ce 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "eslint-config-punchcard": "^1.0.0", "ghooks": "^1.2.4", "input-plugin-datetime": "^0.0.1", + "input-plugin-select": "^0.1.0", "input-plugin-email": "^0.1.0", "input-plugin-quote": "0.0.1", "input-plugin-selects-related": "0.0.1", diff --git a/tests/fixtures/content-types/baz.yml b/tests/fixtures/content-types/baz.yml index 460a94c..f4b87d0 100644 --- a/tests/fixtures/content-types/baz.yml +++ b/tests/fixtures/content-types/baz.yml @@ -74,4 +74,16 @@ attributes: name: Two related select elements id: input-related-selects description: I am a set of selects - + - type: select + name: example dropdown + id: example-dropdown + inputs: + select: + label: Example Dropdown + options: + - label: Option 1 + value: option1 + - label: Option 2 + value: option2 + settings: + multiple: false diff --git a/tests/form.js b/tests/form.js index 8b75a90..ac84068 100644 --- a/tests/form.js +++ b/tests/form.js @@ -139,3 +139,16 @@ test('Form Generation, with ux scripts', t => { t.true(includes(rendered.validation, 'function selectsRelatedScript(', 'includes ux scripts')); }); }); + +test('Form Generation, overrides options in select', t => { + return types.only('baz').then(result => { + return form(result); + }).then(rendered => { + t.true(includes(rendered.html, '', 'determines existence of option1')); + t.true(includes(rendered.html, '', 'determines existence of option2')); + t.false(includes(rendered.html, '', 'determines non-existence of default option 1')); + t.false(includes(rendered.html, '', 'determines non-existence of default option 2')); + t.false(includes(rendered.html, '', 'determines non-existence of default option 3')); + t.false(includes(rendered.html, '', 'determines non-existence of default option 4')); + }); +}); diff --git a/tests/validate.js b/tests/validate.js index 3aaab06..e6deb52 100644 --- a/tests/validate.js +++ b/tests/validate.js @@ -196,7 +196,6 @@ test('Validate - Pass', t => { }; const result = validation(input, ct); - t.true(result, 'All validation passes'); }); });