From fdfb0bcf179853a497b0d6222172ce6f5321854d Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Tue, 31 Mar 2020 18:15:32 -0700 Subject: [PATCH 1/5] Summary: - Changed validate method to except jsonObject only in json_schema_validator/index.js Test: - Updated test to pass --- .../lib/core/project_config/index.js | 3 +- .../project_config/project_config_schema.js | 438 +++++++++--------- .../lib/utils/json_schema_validator/index.js | 9 +- .../json_schema_validator/index.tests.js | 21 +- 4 files changed, 237 insertions(+), 234 deletions(-) diff --git a/packages/optimizely-sdk/lib/core/project_config/index.js b/packages/optimizely-sdk/lib/core/project_config/index.js index 3f26f2376..ad0260d51 100644 --- a/packages/optimizely-sdk/lib/core/project_config/index.js +++ b/packages/optimizely-sdk/lib/core/project_config/index.js @@ -17,7 +17,6 @@ var fns = require('../../utils/fns'); var enums = require('../../utils/enums'); var jsSdkUtils = require('@optimizely/js-sdk-utils'); var configValidator = require('../../utils/config_validator'); -var projectConfigSchema = require('./project_config_schema'); var EXPERIMENT_RUNNING_STATUS = 'Running'; var RESERVED_ATTRIBUTE_PREFIX = '$opt_'; @@ -508,7 +507,7 @@ module.exports = { if (config.skipJSONValidation === true) { config.logger.log(LOG_LEVEL.INFO, jsSdkUtils.sprintf(LOG_MESSAGES.SKIPPING_JSON_VALIDATION, MODULE_NAME)); } else if (config.jsonSchemaValidator) { - config.jsonSchemaValidator.validate(projectConfigSchema, config.datafile); + config.jsonSchemaValidator.validate(config.datafile); config.logger.log(LOG_LEVEL.INFO, jsSdkUtils.sprintf(LOG_MESSAGES.VALID_DATAFILE, MODULE_NAME)); } return module.exports.createProjectConfig(config.datafile); diff --git a/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js b/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js index ecea71159..47a21f6b6 100644 --- a/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js +++ b/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js @@ -18,261 +18,263 @@ /** * Project Config JSON Schema file used to validate the project json datafile */ -module.exports = { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - projectId: { - type: 'string', - required: true, - }, - accountId: { - type: 'string', - required: true, - }, - groups: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - policy: { - type: 'string', - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, +module.exports.getSchema = () => { + return { + $schema: 'http://json-schema.org/draft-04/schema#', + type: 'object', + properties: { + projectId: { + type: 'string', + required: true, + }, + accountId: { + type: 'string', + required: true, + }, + groups: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + policy: { + type: 'string', + required: true, + }, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, + }, }, }, + required: true, }, - required: true, - }, - experiments: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, - status: { - type: 'string', - required: true, - }, - layerId: { - type: 'string', - required: true, - }, - variations: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, + experiments: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, + status: { + type: 'string', + required: true, + }, + layerId: { + type: 'string', + required: true, + }, + variations: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, }, }, + required: true, }, - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, + }, }, }, + required: true, }, - required: true, - }, - audienceIds: { - type: 'array', - items: { - type: 'string', + audienceIds: { + type: 'array', + items: { + type: 'string', + }, + required: true, + }, + forcedVariations: { + type: 'object', + required: true, }, - required: true, - }, - forcedVariations: { - type: 'object', - required: true, }, }, + required: true, }, - required: true, }, }, + required: true, }, - required: true, - }, - experiments: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, - status: { - type: 'string', - required: true, - }, - layerId: { - type: 'string', - required: true, - }, - variations: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, + experiments: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, + status: { + type: 'string', + required: true, + }, + layerId: { + type: 'string', + required: true, + }, + variations: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, }, }, + required: true, }, - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, + }, }, }, + required: true, }, - required: true, - }, - audienceIds: { - type: 'array', - items: { - type: 'string', + audienceIds: { + type: 'array', + items: { + type: 'string', + }, + required: true, + }, + forcedVariations: { + type: 'object', + required: true, }, - required: true, - }, - forcedVariations: { - type: 'object', - required: true, }, }, + required: true, }, - required: true, - }, - events: { - type: 'array', - items: { - type: 'object', - properties: { - key: { - type: 'string', - required: true, - }, - experimentIds: { - type: 'array', - items: { + events: { + type: 'array', + items: { + type: 'object', + properties: { + key: { + type: 'string', + required: true, + }, + experimentIds: { + type: 'array', + items: { + type: 'string', + required: true, + }, + }, + id: { type: 'string', required: true, }, - }, - id: { - type: 'string', - required: true, }, }, + required: true, }, - required: true, - }, - audiences: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - name: { - type: 'string', - required: true, - }, - conditions: { - type: 'string', - required: true, + audiences: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + name: { + type: 'string', + required: true, + }, + conditions: { + type: 'string', + required: true, + }, }, }, + required: true, }, - required: true, - }, - attributes: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, + attributes: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, }, }, + required: true, + }, + version: { + type: 'string', + required: true, + }, + revision: { + type: 'string', + required: true, }, - required: true, - }, - version: { - type: 'string', - required: true, - }, - revision: { - type: 'string', - required: true, }, - }, + } }; diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js index a0cec952f..88683db36 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js @@ -15,6 +15,7 @@ */ var validate = require('json-schema').validate; var sprintf = require('@optimizely/js-sdk-utils').sprintf; +var projectConfigSchema = require('../../core/project_config/project_config_schema'); var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; var MODULE_NAME = 'JSON_SCHEMA_VALIDATOR'; @@ -26,16 +27,16 @@ module.exports = { * @param {Object} jsonObject The object to validate against the schema * @return {Boolean} True if the given object is valid */ - validate: function(jsonSchema, jsonObject) { - if (!jsonSchema) { + validate: function(jsonObject) { + if (!projectConfigSchema.getSchema()) { throw new Error(sprintf(ERROR_MESSAGES.JSON_SCHEMA_EXPECTED, MODULE_NAME)); } if (!jsonObject) { throw new Error(sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, MODULE_NAME)); } - - var result = validate(jsonObject, jsonSchema); + + var result = validate(jsonObject, projectConfigSchema.getSchema()); if (result.valid) { return true; } else { diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js index 7e016ab67..8eca7c7c1 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js @@ -14,6 +14,7 @@ * limitations under the License. */ var chai = require('chai'); +var sinon = require('sinon'); var assert = chai.assert; var jsonSchemaValidator = require('./'); var projectConfigSchema = require('../../core/project_config/project_config_schema'); @@ -26,29 +27,29 @@ describe('lib/utils/json_schema_validator', function() { describe('APIs', function() { describe('validate', function() { it('should validate the given object against the specified schema', function() { - assert.isTrue(jsonSchemaValidator.validate({ type: 'number' }, 4)); + sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); + assert.isTrue(jsonSchemaValidator.validate(4)); + projectConfigSchema.getSchema.restore(); }); it('should throw an error if the object is not valid', function() { assert.throws(function() { - jsonSchemaValidator.validate({ type: 'number' }, 'not a number'); + sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); + jsonSchemaValidator.validate('not a number'); }, 'string value found, but a number is required'); - }); - - it('should throw an error if no schema is passed in', function() { - assert.throws(function() { - jsonSchemaValidator.validate(); - }, sprintf(ERROR_MESSAGES.JSON_SCHEMA_EXPECTED, 'JSON_SCHEMA_VALIDATOR')); + projectConfigSchema.getSchema.restore(); }); it('should throw an error if no json object is passed in', function() { assert.throws(function() { - jsonSchemaValidator.validate({ type: 'number' }); + sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); + jsonSchemaValidator.validate(); }, sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, 'JSON_SCHEMA_VALIDATOR')); + projectConfigSchema.getSchema.restore(); }); it('should validate specified Optimizely datafile with the Optimizely datafile schema', function() { - assert.isTrue(jsonSchemaValidator.validate(projectConfigSchema, testData.getTestProjectConfig())); + assert.isTrue(jsonSchemaValidator.validate(testData.getTestProjectConfig())); }); }); }); From 452252bafad541a7f3f8077c0e97b717978c90cb Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Wed, 1 Apr 2020 15:33:34 -0700 Subject: [PATCH 2/5] Address Matt's comments --- .../project_config/project_config_schema.js | 438 +++++++++--------- .../optimizely-sdk/lib/utils/enums/index.js | 1 - .../lib/utils/json_schema_validator/index.js | 6 +- .../json_schema_validator/index.tests.js | 16 +- 4 files changed, 222 insertions(+), 239 deletions(-) diff --git a/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js b/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js index 47a21f6b6..ecea71159 100644 --- a/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js +++ b/packages/optimizely-sdk/lib/core/project_config/project_config_schema.js @@ -18,263 +18,261 @@ /** * Project Config JSON Schema file used to validate the project json datafile */ -module.exports.getSchema = () => { - return { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - projectId: { - type: 'string', - required: true, - }, - accountId: { - type: 'string', - required: true, - }, - groups: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - policy: { - type: 'string', - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, - }, +module.exports = { + $schema: 'http://json-schema.org/draft-04/schema#', + type: 'object', + properties: { + projectId: { + type: 'string', + required: true, + }, + accountId: { + type: 'string', + required: true, + }, + groups: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + policy: { + type: 'string', + required: true, + }, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, }, }, - required: true, }, - experiments: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, - status: { - type: 'string', - required: true, - }, - layerId: { - type: 'string', - required: true, - }, - variations: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, + required: true, + }, + experiments: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, + status: { + type: 'string', + required: true, + }, + layerId: { + type: 'string', + required: true, + }, + variations: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, }, - }, - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, - }, + key: { + type: 'string', + required: true, }, }, - required: true, }, - audienceIds: { - type: 'array', - items: { - type: 'string', + required: true, + }, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, + }, }, - required: true, }, - forcedVariations: { - type: 'object', - required: true, + required: true, + }, + audienceIds: { + type: 'array', + items: { + type: 'string', }, + required: true, + }, + forcedVariations: { + type: 'object', + required: true, }, }, - required: true, }, + required: true, }, }, - required: true, }, - experiments: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, - status: { - type: 'string', - required: true, - }, - layerId: { - type: 'string', - required: true, - }, - variations: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, + required: true, + }, + experiments: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, + status: { + type: 'string', + required: true, + }, + layerId: { + type: 'string', + required: true, + }, + variations: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, }, - }, - required: true, - }, - trafficAllocation: { - type: 'array', - items: { - type: 'object', - properties: { - entityId: { - type: 'string', - required: true, - }, - endOfRange: { - type: 'integer', - required: true, - }, + key: { + type: 'string', + required: true, }, }, - required: true, - }, - audienceIds: { - type: 'array', - items: { - type: 'string', - }, - required: true, - }, - forcedVariations: { - type: 'object', - required: true, }, + required: true, }, - }, - required: true, - }, - events: { - type: 'array', - items: { - type: 'object', - properties: { - key: { - type: 'string', - required: true, - }, - experimentIds: { - type: 'array', - items: { - type: 'string', - required: true, + trafficAllocation: { + type: 'array', + items: { + type: 'object', + properties: { + entityId: { + type: 'string', + required: true, + }, + endOfRange: { + type: 'integer', + required: true, + }, }, }, - id: { + required: true, + }, + audienceIds: { + type: 'array', + items: { type: 'string', - required: true, }, + required: true, + }, + forcedVariations: { + type: 'object', + required: true, }, }, - required: true, }, - audiences: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - name: { - type: 'string', - required: true, - }, - conditions: { + required: true, + }, + events: { + type: 'array', + items: { + type: 'object', + properties: { + key: { + type: 'string', + required: true, + }, + experimentIds: { + type: 'array', + items: { type: 'string', required: true, }, }, + id: { + type: 'string', + required: true, + }, }, - required: true, }, - attributes: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'string', - required: true, - }, - key: { - type: 'string', - required: true, - }, + required: true, + }, + audiences: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + name: { + type: 'string', + required: true, + }, + conditions: { + type: 'string', + required: true, }, }, - required: true, }, - version: { - type: 'string', - required: true, - }, - revision: { - type: 'string', - required: true, + required: true, + }, + attributes: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + required: true, + }, + key: { + type: 'string', + required: true, + }, + }, }, + required: true, + }, + version: { + type: 'string', + required: true, + }, + revision: { + type: 'string', + required: true, }, - } + }, }; diff --git a/packages/optimizely-sdk/lib/utils/enums/index.js b/packages/optimizely-sdk/lib/utils/enums/index.js index 5561061c9..d18ef5027 100644 --- a/packages/optimizely-sdk/lib/utils/enums/index.js +++ b/packages/optimizely-sdk/lib/utils/enums/index.js @@ -48,7 +48,6 @@ exports.ERROR_MESSAGES = { INVALID_ROLLOUT_ID: '%s: Invalid rollout ID %s attached to feature %s', INVALID_USER_ID: '%s: Provided user ID is in an invalid format.', INVALID_USER_PROFILE_SERVICE: '%s: Provided user profile service instance is in an invalid format: %s.', - JSON_SCHEMA_EXPECTED: '%s: JSON schema expected.', NO_DATAFILE_SPECIFIED: '%s: No datafile specified. Cannot start optimizely.', NO_JSON_PROVIDED: '%s: No JSON object to validate against schema.', NO_VARIATION_FOR_EXPERIMENT_KEY: '%s: No variation key %s defined in datafile for experiment %s.', diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js index 88683db36..94e9f10b7 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js @@ -28,15 +28,11 @@ module.exports = { * @return {Boolean} True if the given object is valid */ validate: function(jsonObject) { - if (!projectConfigSchema.getSchema()) { - throw new Error(sprintf(ERROR_MESSAGES.JSON_SCHEMA_EXPECTED, MODULE_NAME)); - } - if (!jsonObject) { throw new Error(sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, MODULE_NAME)); } - var result = validate(jsonObject, projectConfigSchema.getSchema()); + var result = validate(jsonObject, projectConfigSchema); if (result.valid) { return true; } else { diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js index 8eca7c7c1..e6495282d 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js @@ -26,29 +26,19 @@ var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; describe('lib/utils/json_schema_validator', function() { describe('APIs', function() { describe('validate', function() { - it('should validate the given object against the specified schema', function() { - sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); - assert.isTrue(jsonSchemaValidator.validate(4)); - projectConfigSchema.getSchema.restore(); - }); - it('should throw an error if the object is not valid', function() { assert.throws(function() { - sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); - jsonSchemaValidator.validate('not a number'); - }, 'string value found, but a number is required'); - projectConfigSchema.getSchema.restore(); + jsonSchemaValidator.validate(testData.getMutexFeatureTestsConfig()); + }); }); it('should throw an error if no json object is passed in', function() { assert.throws(function() { - sinon.stub(projectConfigSchema, 'getSchema').returns({ type: 'number' }); jsonSchemaValidator.validate(); }, sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, 'JSON_SCHEMA_VALIDATOR')); - projectConfigSchema.getSchema.restore(); }); - it('should validate specified Optimizely datafile with the Optimizely datafile schema', function() { + it('should validate specified Optimizely datafile', function() { assert.isTrue(jsonSchemaValidator.validate(testData.getTestProjectConfig())); }); }); From 53a693b2f4d13a40f59799c05d72ffd3227e8a5f Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Wed, 1 Apr 2020 15:36:42 -0700 Subject: [PATCH 3/5] Eliminate extraneous spaces --- .../optimizely-sdk/lib/utils/json_schema_validator/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js index 94e9f10b7..69876c6e4 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js @@ -31,7 +31,7 @@ module.exports = { if (!jsonObject) { throw new Error(sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, MODULE_NAME)); } - + var result = validate(jsonObject, projectConfigSchema); if (result.valid) { return true; From 1bcf03942c0a763b468e180817efa04fa8a1ae08 Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Wed, 1 Apr 2020 16:19:22 -0700 Subject: [PATCH 4/5] Remove unnecessary imports --- .../lib/utils/json_schema_validator/index.tests.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js index e6495282d..6ff4603ab 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js @@ -14,10 +14,8 @@ * limitations under the License. */ var chai = require('chai'); -var sinon = require('sinon'); var assert = chai.assert; var jsonSchemaValidator = require('./'); -var projectConfigSchema = require('../../core/project_config/project_config_schema'); var sprintf = require('@optimizely/js-sdk-utils').sprintf; var testData = require('../../tests/test_data.js'); From 75e2f4e75670b112939512ba72f2e437e7ec7b3a Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Thu, 2 Apr 2020 15:30:32 -0700 Subject: [PATCH 5/5] Replaced getMutexFeatureTestConfig with an empty object --- .../lib/utils/json_schema_validator/index.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js index 6ff4603ab..caf2b5284 100644 --- a/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/json_schema_validator/index.tests.js @@ -26,7 +26,7 @@ describe('lib/utils/json_schema_validator', function() { describe('validate', function() { it('should throw an error if the object is not valid', function() { assert.throws(function() { - jsonSchemaValidator.validate(testData.getMutexFeatureTestsConfig()); + jsonSchemaValidator.validate({}); }); });