diff --git a/lib/content-types.js b/lib/content-types.js index 16e0cb4..bfcfa5f 100644 --- a/lib/content-types.js +++ b/lib/content-types.js @@ -36,40 +36,51 @@ const raw = loader; * Merge content type object with input plugin data * * @param {array} content content types array + * @param {object} config - configuration object * * @returns {array} content types array that has been merged with input plugins and user settings */ -const merged = (content) => { +const merged = (content, config) => { let mergedTypes = _.cloneDeep(content); if (content) { return merge(mergedTypes); } - return raw().then(types => { + return raw(config).then(types => { mergedTypes = _.cloneDeep(types); - return merge(mergedTypes); + return merge(mergedTypes, config); }); }; -const onlyCT = (type, config, loadedTypes) => { - const userConfig = config || {}; +/** + * Returns only one content type, merged with input plugins and values + * + * @param {string} type - id of a content type + * @param {object} overrides - contains values for inputs + * @param {array} loadedTypes - array of merged content type objects + * @param {object} config - configuration object + * + * @returns {promise} resolves with promise from `only` function + */ +const onlyCT = (type, overrides, loadedTypes, config) => { + const overs = overrides || {}; let onlyTypes = _.cloneDeep(loadedTypes); if (loadedTypes) { const ct = findCT(type, onlyTypes); - return only(ct, userConfig); + return only(ct, overs, config); } - return merged().then(types => { + return merged(null, config).then(types => { onlyTypes = _.cloneDeep(types); const ct = findCT(type, onlyTypes); - return only(ct, userConfig); + return only(ct, overs, config); }); }; diff --git a/lib/content-types/load.js b/lib/content-types/load.js index cd3d370..41cc266 100644 --- a/lib/content-types/load.js +++ b/lib/content-types/load.js @@ -3,7 +3,6 @@ const dir = require('node-dir'); const yaml = require('js-yaml'); const slugify = require('lodash/kebabCase'); -const globalConfig = require('config'); const path = require('path'); const utils = require('../utils'); @@ -11,20 +10,27 @@ const utils = require('../utils'); /** * Gets all Content Types * + * @param {object} config - configuration object + * * @returns {Promise} - An {Array} containing {Object} for each content type, including `name` {string}, `id` name {string}, and full config {object} loaded from YAML config file */ -const load = () => { +const load = (config) => { + const configuration = config || {}; const types = []; const ids = []; let contentPath = path.join(process.cwd(), 'content-types'); - if (globalConfig.hasOwnProperty('content')) { - if (globalConfig.content.hasOwnProperty('directory')) { - contentPath = globalConfig.content.directory; + return new Promise((resolve, reject) => { + if (typeof configuration !== 'object') { + reject(new Error('Configuration parameter must be an object')); + } + + if (configuration.hasOwnProperty('content')) { + if (configuration.content.hasOwnProperty('directory')) { + contentPath = configuration.content.directory; + } } - } - return new Promise((resolve, reject) => { dir.readFiles(contentPath, { match: /.yml$/, exclude: /^\./, @@ -33,50 +39,50 @@ const load = () => { reject(err); } - const config = yaml.safeLoad(content); + const type = yaml.safeLoad(content); - if (!config.hasOwnProperty('name')) { + if (!type.hasOwnProperty('name')) { reject(new Error('Content types require a name')); } - if (!config.hasOwnProperty('id')) { + if (!type.hasOwnProperty('id')) { reject(new Error('Content types require an id')); } - if (config.id !== slugify(config.id)) { - reject(new Error(`${config.id} needs to be written in kebab case (e.g. ${slugify(config.id)}`)); + if (type.id !== slugify(type.id)) { + reject(new Error(`${type.id} needs to be written in kebab case (e.g. ${slugify(type.id)}`)); } - if (ids.indexOf(config.id) === -1) { - ids.push(config.id); - types.push(config); + if (ids.indexOf(type.id) === -1) { + ids.push(type.id); + types.push(type); } else { - reject(new Error(`Content type ${config.id} is duplicated!`)); + reject(new Error(`Content type ${type.id} is duplicated!`)); } - if (!config.hasOwnProperty('identifier')) { - reject(new Error(`Identifier missing in content type '${config.name}'.`)); + if (!type.hasOwnProperty('identifier')) { + reject(new Error(`Identifier missing in content type '${type.name}'.`)); } - if (config.hasOwnProperty('identifier')) { - if (typeof config.identifier !== 'string') { - reject(new Error(`Identifier in content type '${config.name}' must be a string`)); + if (type.hasOwnProperty('identifier')) { + if (typeof type.identifier !== 'string') { + reject(new Error(`Identifier in content type '${type.name}' must be a string`)); } } // find attribute which is the identifier - const attr = config.attributes.find(a => { - return a.id === config.identifier; + const attr = type.attributes.find(a => { + return a.id === type.identifier; }); - if (!attr) { - reject(new Error(`Identifier '${config.identifier}' is not an attribute in content type '${config.name}'.`)); + if (typeof attr === undefined) { + reject(new Error(`Identifier '${type.identifier}' is not an attribute in content type '${type.name}'.`)); } // check attribute only has one input if (attr.inputs && Array.isArray(Object.keys(attr.inputs)) && Object.keys(attr.inputs).length > 1) { - reject(new Error(`Attribute '${config.identifier}' in content type '${config.name}' cannot be the identifier. Only attributes with one input can be the identifier.`)); + reject(new Error(`Attribute '${type.identifier}' in content type '${type.name}' cannot be the identifier. Only attributes with one input can be the identifier.`)); } next(); diff --git a/lib/content-types/merge.js b/lib/content-types/merge.js index 2bd92d1..4d5e6d8 100644 --- a/lib/content-types/merge.js +++ b/lib/content-types/merge.js @@ -5,20 +5,6 @@ const merge = require('deepmerge'); const uuid = require('uuid'); const _ = require('lodash'); const slugify = require('lodash/kebabCase'); -const globalConfig = require('config'); - -const configPlugins = {}; - -/** - * Retrieve Input Plugins - * - * {Object} - [Plugabilly](https://github.com/Snugug/plugabilly) object - */ -configPlugins.search = _.get(globalConfig, 'content.plugins.directory', []); -if (typeof configPlugins.search === 'string') { - configPlugins.search = [configPlugins.search]; -} -const plugins = plugabilly(_.cloneDeep(configPlugins)).name().containsSync('input-plugin-'); /* * Determine required level @@ -42,10 +28,19 @@ const requiredLevel = (level) => { * Combine content types configurations with input plugins * * @param {array} types - content types configurations + * @param {object} config - configuration object * * @returns {promise} - combined content type with input plugin configs */ -const squish = (types) => { +const squish = (types, config) => { + const configPlugins = {}; + configPlugins.search = _.get(config, 'content.plugins.directory', []); + if (typeof configPlugins.search === 'string') { + configPlugins.search = [configPlugins.search]; + } + + const plugins = plugabilly(_.cloneDeep(configPlugins)).name().containsSync('input-plugin-'); + return new Promise((resolve, reject) => { if (!Array.isArray(types)) { reject(new Error('Content types must be an array')); diff --git a/lib/content-types/only.js b/lib/content-types/only.js index 153fb34..798c082 100644 --- a/lib/content-types/only.js +++ b/lib/content-types/only.js @@ -3,11 +3,19 @@ const merge = require('deepmerge'); const utils = require('../utils'); -const only = (type, configuration) => { +/** + * Retrieves one content type's config object, merged with input plugins and a form's values + * + * @param {object} type merged content type object + * @param {object} overrides values for inputs + * + * @returns {object} content type object merged with input plugins and overrides + */ +const only = (type, overrides) => { return new Promise((resolve) => { const mergedType = type; - const config = configuration; - const configured = Object.keys(config); + const overs = overrides; + const configured = Object.keys(overs); const attrs = mergedType.attributes.map(attribute => { const attr = attribute; let inputs; @@ -19,19 +27,19 @@ const only = (type, configuration) => { inputs = Object.keys(attr.inputs); } - // If there isn't a configuration for this input, move along + // If there isn't a value for this input, move along if (configured.indexOf(attr.id) === -1) { return attr; } // check if repeatable but not an array - if (attr.hasOwnProperty('repeatable') && typeof attr.repeatable === 'object' && !Array.isArray(config[attr.id])) { - config[attr.id] = [config[attr.id]]; + if (attr.hasOwnProperty('repeatable') && typeof attr.repeatable === 'object' && !Array.isArray(overs[attr.id])) { + overs[attr.id] = [overs[attr.id]]; } // Flattens multiple instances and updates ids and names - if (Array.isArray(config[attr.id])) { - attr.inputs = config[attr.id].map((data, index) => { + if (Array.isArray(overs[attr.id])) { + attr.inputs = overs[attr.id].map((data, index) => { const instance = merge(attr.inputs[0], data); inputs.forEach(input => { instance[input].validation = attribute.inputs[0][input].validation; @@ -44,8 +52,8 @@ const only = (type, configuration) => { }); } else { - // Merge configuration for the inputs and the configuration - attr.inputs = merge(attr.inputs, config[attr.id]); + // Merge configuration for the inputs and the overs + attr.inputs = merge(attr.inputs, overs[attr.id]); // Override the validation, type, and ID for all inputs that matter inputs.forEach(input => { diff --git a/lib/form.js b/lib/form.js index 544e922..80a77dc 100644 --- a/lib/form.js +++ b/lib/form.js @@ -4,14 +4,22 @@ const html = require('./form/html'); const scripts = require('./form/scripts'); const validate = require('./form/validate'); -// const css = require('./form/css'); -const form = (type, errors) => { +/** + * Form configuration creator! + * + * @param {InputType} type - Input type being rendered + * @param {FormInputValues} errors - Errors associated with form inputs + * @param {object} config - application configuration + * + * @returns {promise} - promise from scripts + */ +const form = (type, errors, config) => { const rendered = {}; return html(type, errors).then(result => { rendered.html = result; - return scripts(type); + return scripts(type, config); }).then(result => { rendered.scripts = result; }).then(() => { diff --git a/lib/form/scripts.js b/lib/form/scripts.js index 2ccd90b..8e64698 100644 --- a/lib/form/scripts.js +++ b/lib/form/scripts.js @@ -6,14 +6,19 @@ const fs = require('fs'); const path = require('path'); const _ = require('lodash'); const utils = require('../utils'); -const globalConfig = require('config'); const formJS = fs.readdirSync(path.join(__dirname, 'js')).map(script => { return fs.readFileSync(path.join(__dirname, 'js', script)); }).join('\n\n'); -// const util = require('../util'); - -const rendered = (type) => { +/** + * Form configuration creator! + * + * @param {InputType} type - Input type being rendered + * @param {object} config - application configuration + * + * @returns {string} - form script code + */ +const rendered = (type, config) => { return new Promise((res, rej) => { const b = browserify(); const s = new stream.Readable(); @@ -25,7 +30,7 @@ const rendered = (type) => { let plugins = type.attributes.map(plugin => { return plugin.type; }); - const existing = utils.getPlugins(globalConfig); + const existing = utils.getPlugins(config); plugins = plugins.filter((item, pos, self) => { return self.indexOf(item) === pos; diff --git a/package.json b/package.json index 1e31ef8..1bac030 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "license": "Apache-2.0", "dependencies": { "browserify": "^13.0.1", - "config": "^1.20.4", "deepmerge": "^0.2.10", "js-yaml": "^3.5.3", "lodash": "^4.14.1", diff --git a/tests/content-types.js b/tests/content-types.js index d985f61..017c7e8 100644 --- a/tests/content-types.js +++ b/tests/content-types.js @@ -2,8 +2,10 @@ import test from 'ava'; import cloneDeep from 'lodash/cloneDeep'; import types from '../lib/content-types'; import only from '../lib/content-types/only.js'; -import barInput from './fixtures/objects//bar-input.js'; -import barExpected from './fixtures/objects//bar-expected.js'; + +import config from './fixtures/config/default'; +import barInput from './fixtures/objects/bar-input.js'; +import barExpected from './fixtures/objects/bar-expected.js'; const correctCT = [{ name: 'Foo', @@ -78,9 +80,29 @@ test('Content Types', t => { }); }); -test('merged', t => { +test('returns content types from default directory when no parameters', t => { return types() .then(result => { + t.true(Array.isArray(result), 'Should return an array'); + t.is(result.length, 1, 'Should only have one content type'); + t.is(result[0].name, 'Content Type FOO', 'Get first content type name'); + t.is(result[0].description, 'A non-traditionally placed fixture to test the default content-types directory', 'Get first content type desc'); + t.is(result[0].id, 'default-config-foo', 'Get first content type id'); + }); +}); + +test('rejects when config is not an object', t => { + return types('', 'config') + .catch(err => { + t.is(err.message, 'Configuration parameter must be an object', 'Should return an error with non-object config'); + }); +}); + +test('returns all types from configured content type directory', t => { + return types('', config) + .then(result => { + t.true(Array.isArray(result), 'Should return an array'); + t.is(result.length, 3, 'Should only have one content type'); t.is(result[0].name, 'Content Type BAR', 'Get first content type name'); t.is(result[0].description, 'Bar Baz Foo', 'Get first content type desc'); t.is(result[0].id, 'bar', 'Get first content type id'); diff --git a/tests/content-types/default-config-foo.yml b/tests/content-types/default-config-foo.yml new file mode 100644 index 0000000..50a4e71 --- /dev/null +++ b/tests/content-types/default-config-foo.yml @@ -0,0 +1,8 @@ +name: Content Type FOO +description: A non-traditionally placed fixture to test the default content-types directory +id: default-config-foo +identifier: title +attributes: + - type: text + name: Title + id: title diff --git a/tests/fixtures/config/default.js b/tests/fixtures/config/default.js new file mode 100644 index 0000000..98ec9c5 --- /dev/null +++ b/tests/fixtures/config/default.js @@ -0,0 +1,8 @@ +'use strict'; +const path = require('path'); + +module.exports = { + content: { + directory: path.join(__dirname, '../content-types/good'), + }, +}; diff --git a/tests/fixtures/content-types/alternate-dir/bar.yml b/tests/fixtures/content-types/alternate-dir/bar.yml new file mode 100644 index 0000000..aed361e --- /dev/null +++ b/tests/fixtures/content-types/alternate-dir/bar.yml @@ -0,0 +1,34 @@ +name: Content Type BAR +description: Bar Baz Foo +id: alt-bar +identifier: something-new +attributes: + - type: text + id: something-new + name: SOme New THING + description: I am the Bar Content Type Config text field description + - type: textarea + id: my-textarea + name: My Awesome Text Area + description: I am the Bar Content Type Config textarea description + - type: email + id: my-email + name: Email Address of Awesome + repeatable: + min: 2 + max: 4 + - type: quote + id: my-quote + repeatable: true + name: My Quote + description: I am the Bar Content Type Config quote description + - type: checkbox + id: my-checkbox + name: checkbox + repeatable: + min: 1 + - type: checkbox + id: my-checkbox-other + name: checkbox + repeatable: + max: 10 diff --git a/tests/fixtures/content-types/alternate-dir/baz.yml b/tests/fixtures/content-types/alternate-dir/baz.yml new file mode 100644 index 0000000..b620a54 --- /dev/null +++ b/tests/fixtures/content-types/alternate-dir/baz.yml @@ -0,0 +1,90 @@ +name: Content Type Baz +description: Bar Baz Foo +id: alt-baz +identifier: input-required-save +attributes: + - type: text + name: Plugin required save + id: plugin-required-save + description: I am a plugin that is required to save + required: 2 + inputs: + text: + settings: + empty: true + - type: text + name: Input required save + id: input-required-save + description: I am an input that is required to save + inputs: + text: + required: 'save' + settings: + empty: true + - type: text + name: Plugin required publish + id: plugin-required-publish + description: I am a plugin that is required to publish + required: 1 + inputs: + text: + settings: + empty: true + - type: text + name: Input required publish + id: input-required-publish + description: I am an input that is required to publish + inputs: + text: + required: 'publish' + settings: + empty: true + - type: text + name: Plugin required bad level + id: plugin-required-bad-level + description: I am a plugin with an incorrect required level + required: 3 + inputs: + text: + settings: + empty: true + - type: text + name: Input required bad level + id: input-required-bad-level + description: I am an input with an incorrect required level + inputs: + text: + required: 'smublish' + settings: + empty: true + - type: quote + name: MULTI Plugin required save + id: multi-plugin-required-save + description: I am a multi-plugin that is required to save + required: true + - type: quote + name: MULTI Input required publish + id: multi-input-required-publish + description: I am a multi-input that is required to publish + inputs: + author: + required: 'publish' + settings: + empty: true + - type: selects-related + 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/fixtures/content-types/alternate-dir/foo.yml b/tests/fixtures/content-types/alternate-dir/foo.yml new file mode 100644 index 0000000..87a4d34 --- /dev/null +++ b/tests/fixtures/content-types/alternate-dir/foo.yml @@ -0,0 +1,34 @@ +name: Content Type FOO +description: Foo Bar Baz +id: alt-foo +identifier: new-text-thing +attributes: + - type: text + name: SOme New THING + id: new-text-thing + description: I am the Foo Content Type Config text field description + inputs: + text: + settings: + empty: false + - type: email + id: email-field + name: My email field + description: I am the Foo Content Type Config email field description + - type: datetime + id: date-and-time + name: Datetime + inputs: + datetimeDate: + settings: + empty: false + - type: textarea + id: my-textarea + name: Super Text Area of Doom! + description: I am the Foo Content Type Config textarea description + inputs: + textarea: + validation: bob + type: text + label: Banana Bob + placeholder: 'Writers, start your novels' diff --git a/tests/fixtures/content-types/bar.yml b/tests/fixtures/content-types/good/bar.yml similarity index 100% rename from tests/fixtures/content-types/bar.yml rename to tests/fixtures/content-types/good/bar.yml diff --git a/tests/fixtures/content-types/baz.yml b/tests/fixtures/content-types/good/baz.yml similarity index 100% rename from tests/fixtures/content-types/baz.yml rename to tests/fixtures/content-types/good/baz.yml diff --git a/tests/fixtures/content-types/foo.yml b/tests/fixtures/content-types/good/foo.yml similarity index 100% rename from tests/fixtures/content-types/foo.yml rename to tests/fixtures/content-types/good/foo.yml diff --git a/tests/form.js b/tests/form.js index 09ddd86..d946a8b 100644 --- a/tests/form.js +++ b/tests/form.js @@ -1,7 +1,10 @@ import test from 'ava'; +import includes from 'lodash/includes'; + import types from '../lib/content-types'; import form from '../lib/form'; -import includes from 'lodash/includes'; + +import config from './fixtures/config/default'; import barInput from './fixtures/objects/bar-expected.js'; test('All Form Goodies', t => { @@ -11,7 +14,7 @@ test('All Form Goodies', t => { }); test('Form Generation', t => { - return types.only('foo').then(result => { + return types.only('foo', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(rendered.hasOwnProperty('scripts'), 'Form JS generated'); @@ -24,7 +27,7 @@ test('Form Generation', t => { }); test('Form Generation, Again', t => { - return types.only('foo').then(result => { + return types.only('foo', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(rendered.hasOwnProperty('scripts'), 'Form JS generated'); @@ -36,7 +39,7 @@ test('Form Generation, Again', t => { }); test('Form Generation, Again Again', t => { - return types.only('bar').then(result => { + return types.only('bar', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(rendered.hasOwnProperty('scripts'), 'Form JS generated'); @@ -48,7 +51,7 @@ test('Form Generation, Again Again', t => { }); test('Form Generation, with required attributes and inputs', t => { - return types.only('baz').then(result => { + return types.only('baz', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(rendered.hasOwnProperty('scripts'), 'Form JS generated'); @@ -63,7 +66,7 @@ test('Form Generation, with required attributes and inputs', t => { }); test('Form Generation, with identifier automatically required', t => { - return types.only('foo').then(result => { + return types.only('foo', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(rendered.hasOwnProperty('scripts'), 'Form JS generated'); @@ -78,7 +81,7 @@ test('Form Generation, with identifier automatically required', t => { }); test('Form Generation, with required, with classes on a label', t => { - return types.only('baz').then(rslt => { + return types.only('baz', {}, '', config).then(rslt => { const result = rslt; result.attributes[0].html = ''; result.attributes[2].html = ''; @@ -97,7 +100,7 @@ test('Form Generation, with required, with classes on a label', t => { }); test('Form Generation, with required attributes and inputs that have wrong levels', t => { - return types.only('baz').then(rslt => { + return types.only('baz', {}, '', config).then(rslt => { const result = rslt; result.attributes[5].html = ''; @@ -109,7 +112,7 @@ test('Form Generation, with required attributes and inputs that have wrong level }); test('Form Generation, required knows publish vs save', t => { - return types.only('baz').then(result => { + return types.only('baz', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(includes(rendered.html, '
', 'determines save for plugin')); @@ -120,7 +123,7 @@ test('Form Generation, required knows publish vs save', t => { test('Form Generation, with errors', t => { let errorMsg; - return types.only('foo').then(result => { + return types.only('foo', {}, '', config).then(result => { const errors = { [result.attributes[1].inputs.email.name]: 'I am a test error', }; @@ -140,7 +143,7 @@ test('Form Generation, with errors', t => { }); test('Form Generation, with ux scripts', t => { - return types.only('baz').then(result => { + return types.only('baz', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(includes(rendered.scripts, 'function selectsRelatedScript(', 'includes ux scripts')); @@ -148,7 +151,7 @@ test('Form Generation, with ux scripts', t => { }); test('Form Generation, overrides options in select', t => { - return types.only('baz').then(result => { + return types.only('baz', {}, '', config).then(result => { return form(result); }).then(rendered => { t.true(includes(rendered.html, '', 'determines existence of option1')); diff --git a/tests/validate.js b/tests/validate.js index bbddd3e..538fd10 100644 --- a/tests/validate.js +++ b/tests/validate.js @@ -1,7 +1,10 @@ import test from 'ava'; + import types from '../lib/content-types'; import validation from '../lib/form/validate'; +import config from './fixtures/config/default'; + test('Split Values - Pass', t => { const input = { @@ -187,7 +190,7 @@ test('Join Values - Throws Error', t => { }); test('Validate - Pass', t => { - return types.only('bar').then(ct => { + return types.only('bar', {}, '', config).then(ct => { const input = { 'something-new--text': 'Foo bar baz', 'my-textarea--textarea': 'This is some long text', @@ -201,7 +204,7 @@ test('Validate - Pass', t => { }); test('Validate - Fail', t => { - return types.only('bar').then(ct => { + return types.only('bar', {}, '', config).then(ct => { const input = { 'something-new--text': 'Foo bar baz', 'my-textarea--textarea': 'This is some long text', @@ -219,7 +222,7 @@ test('Validate - Fail', t => { }); test('Validate Repeatable - Pass', t => { - return types.only('bar').then(ct => { + return types.only('bar', {}, '', config).then(ct => { const input = { 'something-new--text': 'Foo bar baz', 'my-textarea--textarea': 'This is some long text', @@ -232,7 +235,7 @@ test('Validate Repeatable - Pass', t => { }); test('Validate Repeatable - Fail', t => { - return types.only('bar').then(ct => { + return types.only('bar', {}, '', config).then(ct => { const input = { 'something-new--text': 'Foo bar baz', 'my-textarea--textarea': 'This is some long text', @@ -247,7 +250,7 @@ test('Validate Repeatable - Fail', t => { }); test('Required - Pass', t => { - return types.only('baz').then(ct => { + return types.only('baz', {}, '', config).then(ct => { const input = { 'plugin-required-save--text': 'Baz plugin', 'input-required-save--text': 'Baz input', @@ -260,7 +263,7 @@ test('Required - Pass', t => { }); test('Required Publish with Empty Save', t => { - return types.only('baz').then(ct => { + return types.only('baz', {}, '', config).then(ct => { const input = { 'plugin-required-save--text': '', 'input-required-save--text': '', @@ -278,7 +281,7 @@ test('Required Publish with Empty Save', t => { }); test('Required Publish with Empty Publish and Save', t => { - return types.only('baz').then(ct => { + return types.only('baz', {}, '', config).then(ct => { const input = { 'plugin-required-save--text': '', 'input-required-publish--text': '', @@ -297,7 +300,7 @@ test('Required Publish with Empty Publish and Save', t => { test('Required Save with Empty Publish', t => { - return types.only('baz').then(ct => { + return types.only('baz', {}, '', config).then(ct => { const input = { 'plugin-required-publish--text': '', 'input-required-publish--text': '', @@ -310,7 +313,7 @@ test('Required Save with Empty Publish', t => { }); test('Validation fails if required check is wrong', t => { - return types.only('baz').then(ct => { + return types.only('baz', {}, '', config).then(ct => { const input = { 'plugin-required-publish--text': '', 'input-required-publish--text': '',