diff --git a/packages/optimizely-sdk/lib/optimizely/index.js b/packages/optimizely-sdk/lib/optimizely/index.js index 9b2d1e5e4..fc99ced13 100644 --- a/packages/optimizely-sdk/lib/optimizely/index.js +++ b/packages/optimizely-sdk/lib/optimizely/index.js @@ -17,7 +17,7 @@ import { sprintf, objectValues } from '@optimizely/js-sdk-utils'; import * as eventProcessor from '@optimizely/js-sdk-event-processor'; import fns from '../utils/fns' -import attributesValidator from '../utils/attributes_validator'; +import { validate } from '../utils/attributes_validator'; import decisionService from '../core/decision_service'; import enums from '../utils/enums'; import eventBuilder from '../core/event_builder/index.js'; @@ -499,7 +499,7 @@ Optimizely.prototype.__validateInputs = function(stringInputs, userAttributes, e } } if (userAttributes) { - attributesValidator.validate(userAttributes); + validate(userAttributes); } if (eventTags) { eventTagsValidator.validate(eventTags); diff --git a/packages/optimizely-sdk/lib/utils/attributes_validator/index.js b/packages/optimizely-sdk/lib/utils/attributes_validator/index.js index a080e895d..2b15c27a1 100644 --- a/packages/optimizely-sdk/lib/utils/attributes_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/attributes_validator/index.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, 2018-2019, Optimizely + * Copyright 2016, 2018-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,43 +13,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { sprintf } from '@optimizely/js-sdk-utils'; -/** - * Provides utility method for validating that the attributes user has provided are valid - */ +import fns from '../../utils/fns'; +import { ERROR_MESSAGES } from '../enums'; -var sprintf = require('@optimizely/js-sdk-utils').sprintf; -var fns = require('../../utils/fns'); - -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; var MODULE_NAME = 'ATTRIBUTES_VALIDATOR'; -module.exports = { - /** - * Validates user's provided attributes - * @param {Object} attributes - * @return {boolean} True if the attributes are valid - * @throws If the attributes are not valid - */ - validate: function(attributes) { - if (typeof attributes === 'object' && !Array.isArray(attributes) && attributes !== null) { - Object.keys(attributes).forEach(function(key) { - if (typeof attributes[key] === 'undefined') { - throw new Error(sprintf(ERROR_MESSAGES.UNDEFINED_ATTRIBUTE, MODULE_NAME, key)); - } - }); - return true; - } else { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_ATTRIBUTES, MODULE_NAME)); - } - }, +/** + * Validates user's provided attributes + * @param {Object} attributes + * @return {boolean} True if the attributes are valid + * @throws If the attributes are not valid + */ +export var validate = function(attributes) { + if (typeof attributes === 'object' && !Array.isArray(attributes) && attributes !== null) { + Object.keys(attributes).forEach(function(key) { + if (typeof attributes[key] === 'undefined') { + throw new Error(sprintf(ERROR_MESSAGES.UNDEFINED_ATTRIBUTE, MODULE_NAME, key)); + } + }); + return true; + } else { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_ATTRIBUTES, MODULE_NAME)); + } +}; + +export var isAttributeValid = function(attributeKey, attributeValue) { + return ( + typeof attributeKey === 'string' && + (typeof attributeValue === 'string' || + typeof attributeValue === 'boolean' || + (fns.isNumber(attributeValue) && fns.isSafeInteger(attributeValue))) + ); +}; - isAttributeValid: function(attributeKey, attributeValue) { - return ( - typeof attributeKey === 'string' && - (typeof attributeValue === 'string' || - typeof attributeValue === 'boolean' || - (fns.isNumber(attributeValue) && fns.isSafeInteger(attributeValue))) - ); - }, +/** + * Provides utility method for validating that the attributes user has provided are valid + */ +export default { + validate: validate, + isAttributeValid: isAttributeValid, }; diff --git a/packages/optimizely-sdk/lib/utils/attributes_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/attributes_validator/index.tests.js index 647695a72..96ebbd7f6 100644 --- a/packages/optimizely-sdk/lib/utils/attributes_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/attributes_validator/index.tests.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, 2018-2019, Optimizely + * Copyright 2016, 2018-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var chai = require('chai'); -var assert = chai.assert; -var sprintf = require('@optimizely/js-sdk-utils').sprintf; -var attributesValidator = require('./'); -var fns = require('./../fns/'); +import { assert } from 'chai'; +import { sprintf } from '@optimizely/js-sdk-utils'; -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; +import attributesValidator from './'; +import { ERROR_MESSAGES } from '../enums'; describe('lib/utils/attributes_validator', function() { describe('APIs', function() { diff --git a/packages/optimizely-sdk/lib/utils/config_validator/index.js b/packages/optimizely-sdk/lib/utils/config_validator/index.js index 499916a9d..dfdb51dea 100644 --- a/packages/optimizely-sdk/lib/utils/config_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/config_validator/index.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, 2018, 2019 Optimizely + * Copyright 2016, 2018-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,70 +13,75 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var sprintf = require('@optimizely/js-sdk-utils').sprintf; +import { sprintf } from '@optimizely/js-sdk-utils'; -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; -var MODULE_NAME = 'CONFIG_VALIDATOR'; -var DATAFILE_VERSIONS = require('../enums').DATAFILE_VERSIONS; +import { + ERROR_MESSAGES, + DATAFILE_VERSIONS, +} from '../enums'; +var MODULE_NAME = 'CONFIG_VALIDATOR'; var SUPPORTED_VERSIONS = [DATAFILE_VERSIONS.V2, DATAFILE_VERSIONS.V3, DATAFILE_VERSIONS.V4]; /** - * Provides utility methods for validating that the configuration options are valid + * Validates the given config options + * @param {Object} config + * @param {Object} config.errorHandler + * @param {Object} config.eventDispatcher + * @param {Object} config.logger + * @return {Boolean} True if the config options are valid + * @throws If any of the config options are not valid */ -module.exports = { - /** - * Validates the given config options - * @param {Object} config - * @param {Object} config.errorHandler - * @param {Object} config.eventDispatcher - * @param {Object} config.logger - * @return {Boolean} True if the config options are valid - * @throws If any of the config options are not valid - */ - validate: function(config) { - if (config.errorHandler && typeof config.errorHandler.handleError !== 'function') { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_ERROR_HANDLER, MODULE_NAME)); - } +export var validate = function(config) { + if (config.errorHandler && typeof config.errorHandler.handleError !== 'function') { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_ERROR_HANDLER, MODULE_NAME)); + } - if (config.eventDispatcher && typeof config.eventDispatcher.dispatchEvent !== 'function') { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_DISPATCHER, MODULE_NAME)); - } + if (config.eventDispatcher && typeof config.eventDispatcher.dispatchEvent !== 'function') { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_DISPATCHER, MODULE_NAME)); + } - if (config.logger && typeof config.logger.log !== 'function') { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_LOGGER, MODULE_NAME)); - } + if (config.logger && typeof config.logger.log !== 'function') { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_LOGGER, MODULE_NAME)); + } - return true; - }, + return true; +}; - /** - * Validates the datafile - * @param {string} datafile - * @return {Boolean} True if the datafile is valid - * @throws If the datafile is not valid for any of the following reasons: - - The datafile string is undefined - - The datafile string cannot be parsed as a JSON object - - The datafile version is not supported - */ - validateDatafile: function(datafile) { - if (!datafile) { - throw new Error(sprintf(ERROR_MESSAGES.NO_DATAFILE_SPECIFIED, MODULE_NAME)); - } +/** + * Validates the datafile + * @param {string} datafile + * @return {Boolean} True if the datafile is valid + * @throws If the datafile is not valid for any of the following reasons: + - The datafile string is undefined + - The datafile string cannot be parsed as a JSON object + - The datafile version is not supported + */ +export var validateDatafile = function(datafile) { + if (!datafile) { + throw new Error(sprintf(ERROR_MESSAGES.NO_DATAFILE_SPECIFIED, MODULE_NAME)); + } - if (typeof datafile === 'string' || datafile instanceof String) { - // Attempt to parse the datafile string - try { - datafile = JSON.parse(datafile); - } catch (ex) { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE_MALFORMED, MODULE_NAME)); - } + if (typeof datafile === 'string' || datafile instanceof String) { + // Attempt to parse the datafile string + try { + datafile = JSON.parse(datafile); + } catch (ex) { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE_MALFORMED, MODULE_NAME)); } + } - if (SUPPORTED_VERSIONS.indexOf(datafile.version) === -1) { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE_VERSION, MODULE_NAME, datafile.version)); - } + if (SUPPORTED_VERSIONS.indexOf(datafile.version) === -1) { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE_VERSION, MODULE_NAME, datafile.version)); + } + + return true; +}; - return true; - }, +/** + * Provides utility methods for validating that the configuration options are valid + */ +export default { + validate: validate, + validateDatafile: validateDatafile, }; diff --git a/packages/optimizely-sdk/lib/utils/config_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/config_validator/index.tests.js index 1776bdc1f..65c4c24d9 100644 --- a/packages/optimizely-sdk/lib/utils/config_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/config_validator/index.tests.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, 2018, 2019 Optimizely + * Copyright 2016, 2018-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var chai = require('chai'); -var assert = chai.assert; -var configValidator = require('./'); -var sprintf = require('@optimizely/js-sdk-utils').sprintf; -var testData = require('../../tests/test_data'); +import { assert } from 'chai'; +import { sprintf } from '@optimizely/js-sdk-utils'; -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; +import configValidator from './'; +import { ERROR_MESSAGES } from '../enums'; +import testData from '../../tests/test_data'; describe('lib/utils/config_validator', function() { describe('APIs', function() { diff --git a/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js b/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js index c7fb146f7..41521cc48 100644 --- a/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js @@ -1,5 +1,5 @@ /** - * Copyright 2019, Optimizely + * Copyright 2019-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,28 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -var fns = require('../fns'); +import { isSafeInteger } from '../fns'; /** * Return true if the argument is a valid event batch size, false otherwise * @param {*} eventBatchSize * @returns boolean */ -function validateEventBatchSize(eventBatchSize) { - return fns.isSafeInteger(eventBatchSize) && eventBatchSize >= 1; -} +export var validateEventBatchSize = function(eventBatchSize) { + return isSafeInteger(eventBatchSize) && eventBatchSize >= 1; +}; /** * Return true if the argument is a valid event flush interval, false otherwise * @param {*} eventFlushInterval * @returns boolean */ -function validateEventFlushInterval(eventFlushInterval) { - return fns.isSafeInteger(eventFlushInterval) && eventFlushInterval > 0; -} +export var validateEventFlushInterval = function(eventFlushInterval) { + return isSafeInteger(eventFlushInterval) && eventFlushInterval > 0; +}; -module.exports = { +export default { validateEventBatchSize: validateEventBatchSize, validateEventFlushInterval: validateEventFlushInterval, }; diff --git a/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.tests.js index a6c9e9ad6..6ecc6a134 100644 --- a/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.tests.js @@ -1,5 +1,5 @@ /** - * Copyright 2019, Optimizely + * Copyright 2019-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from 'chai'; -var chai = require('chai'); -var eventProcessorConfigValidator = require('./index'); - -var assert = chai.assert; +import eventProcessorConfigValidator from './index'; describe('utils/event_processor_config_validator', function() { describe('validateEventFlushInterval', function() { diff --git a/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js b/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js index 9d83f3a2d..18f8f38cc 100644 --- a/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js +++ b/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, 2019 Optimizely + * Copyright 2017, 2019-2020 Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,57 +13,62 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { sprintf } from '@optimizely/js-sdk-utils'; + +import { + LOG_LEVEL, + LOG_MESSAGES, + RESERVED_EVENT_KEYWORDS, +} from '../enums'; /** * Provides utility method for parsing event tag values */ -var enums = require('../enums'); -var sprintf = require('@optimizely/js-sdk-utils').sprintf; - -var LOG_LEVEL = enums.LOG_LEVEL; -var LOG_MESSAGES = enums.LOG_MESSAGES; var MODULE_NAME = 'EVENT_TAG_UTILS'; -var REVENUE_EVENT_METRIC_NAME = enums.RESERVED_EVENT_KEYWORDS.REVENUE; -var VALUE_EVENT_METRIC_NAME = enums.RESERVED_EVENT_KEYWORDS.VALUE; +var REVENUE_EVENT_METRIC_NAME = RESERVED_EVENT_KEYWORDS.REVENUE; +var VALUE_EVENT_METRIC_NAME = RESERVED_EVENT_KEYWORDS.VALUE; -module.exports = { - /** - * Grab the revenue value from the event tags. "revenue" is a reserved keyword. - * @param {Object} eventTags - * @param {Object} logger - * @return {Integer|null} - */ - getRevenueValue: function(eventTags, logger) { - if (eventTags && eventTags.hasOwnProperty(REVENUE_EVENT_METRIC_NAME)) { - var rawValue = eventTags[REVENUE_EVENT_METRIC_NAME]; - var parsedRevenueValue = parseInt(rawValue, 10); - if (isNaN(parsedRevenueValue)) { - logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE_REVENUE, MODULE_NAME, rawValue)); - return null; - } - logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.PARSED_REVENUE_VALUE, MODULE_NAME, parsedRevenueValue)); - return parsedRevenueValue; +/** + * Grab the revenue value from the event tags. "revenue" is a reserved keyword. + * @param {Object} eventTags + * @param {Object} logger + * @return {Integer|null} + */ +export var getRevenueValue = function(eventTags, logger) { + if (eventTags && eventTags.hasOwnProperty(REVENUE_EVENT_METRIC_NAME)) { + var rawValue = eventTags[REVENUE_EVENT_METRIC_NAME]; + var parsedRevenueValue = parseInt(rawValue, 10); + if (isNaN(parsedRevenueValue)) { + logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE_REVENUE, MODULE_NAME, rawValue)); + return null; } - return null; - }, + logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.PARSED_REVENUE_VALUE, MODULE_NAME, parsedRevenueValue)); + return parsedRevenueValue; + } + return null; +}; - /** - * Grab the event value from the event tags. "value" is a reserved keyword. - * @param {Object} eventTags - * @param {Object} logger - * @return {Number|null} - */ - getEventValue: function(eventTags, logger) { - if (eventTags && eventTags.hasOwnProperty(VALUE_EVENT_METRIC_NAME)) { - var rawValue = eventTags[VALUE_EVENT_METRIC_NAME]; - var parsedEventValue = parseFloat(rawValue); - if (isNaN(parsedEventValue)) { - logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE_VALUE, MODULE_NAME, rawValue)); - return null; - } - logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.PARSED_NUMERIC_VALUE, MODULE_NAME, parsedEventValue)); - return parsedEventValue; +/** + * Grab the event value from the event tags. "value" is a reserved keyword. + * @param {Object} eventTags + * @param {Object} logger + * @return {Number|null} + */ +export var getEventValue = function(eventTags, logger) { + if (eventTags && eventTags.hasOwnProperty(VALUE_EVENT_METRIC_NAME)) { + var rawValue = eventTags[VALUE_EVENT_METRIC_NAME]; + var parsedEventValue = parseFloat(rawValue); + if (isNaN(parsedEventValue)) { + logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE_VALUE, MODULE_NAME, rawValue)); + return null; } - return null; - }, + logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.PARSED_NUMERIC_VALUE, MODULE_NAME, parsedEventValue)); + return parsedEventValue; + } + return null; +}; + +export default { + getRevenueValue: getRevenueValue, + getEventValue: getEventValue, }; diff --git a/packages/optimizely-sdk/lib/utils/event_tag_utils/index.tests.js b/packages/optimizely-sdk/lib/utils/event_tag_utils/index.tests.js index 910689a01..7f15f1296 100644 --- a/packages/optimizely-sdk/lib/utils/event_tag_utils/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/event_tag_utils/index.tests.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Optimizely + * Copyright 2017, 2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var chai = require('chai'); -var assert = chai.assert; -var sinon = require('sinon'); -var eventTagUtils = require('./'); +import sinon from 'sinon'; +import { assert } from 'chai'; + +import eventTagUtils from './'; describe('lib/utils/event_tag_utils', function() { var mockLogger; diff --git a/packages/optimizely-sdk/lib/utils/event_tags_validator/index.js b/packages/optimizely-sdk/lib/utils/event_tags_validator/index.js index 42268a716..2d6303d8a 100644 --- a/packages/optimizely-sdk/lib/utils/event_tags_validator/index.js +++ b/packages/optimizely-sdk/lib/utils/event_tags_validator/index.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Optimizely + * Copyright 2017, 2020 Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,24 +17,26 @@ /** * Provides utility method for validating that event tags user has provided are valid */ +import { sprintf } from '@optimizely/js-sdk-utils'; -var sprintf = require('@optimizely/js-sdk-utils').sprintf; +import { ERROR_MESSAGES } from '../enums'; -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; var MODULE_NAME = 'EVENT_TAGS_VALIDATOR'; -module.exports = { - /** - * Validates user's provided event tags - * @param {Object} event tags - * @return {boolean} True if event tags are valid - * @throws If event tags are not valid - */ - validate: function(eventTags) { - if (typeof eventTags === 'object' && !Array.isArray(eventTags) && eventTags !== null) { - return true; - } else { - throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, MODULE_NAME)); - } - }, -}; +/** + * Validates user's provided event tags + * @param {Object} event tags + * @return {boolean} True if event tags are valid + * @throws If event tags are not valid + */ +export var validate = function(eventTags) { + if (typeof eventTags === 'object' && !Array.isArray(eventTags) && eventTags !== null) { + return true; + } else { + throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, MODULE_NAME)); + } +} + +export default { + validate: validate, +} diff --git a/packages/optimizely-sdk/lib/utils/event_tags_validator/index.tests.js b/packages/optimizely-sdk/lib/utils/event_tags_validator/index.tests.js index ce8a0be49..4dde65d18 100644 --- a/packages/optimizely-sdk/lib/utils/event_tags_validator/index.tests.js +++ b/packages/optimizely-sdk/lib/utils/event_tags_validator/index.tests.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Optimizely + * Copyright 2017, 2020 Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,30 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var chai = require('chai'); -var assert = chai.assert; -var sprintf = require('@optimizely/js-sdk-utils').sprintf; -var eventTagsValidator = require('./'); +import { assert } from 'chai'; +import { sprintf } from '@optimizely/js-sdk-utils'; -var ERROR_MESSAGES = require('../enums').ERROR_MESSAGES; +import { validate } from './'; +import { ERROR_MESSAGES } from'../enums'; describe('lib/utils/event_tags_validator', function() { describe('APIs', function() { describe('validate', function() { it('should validate the given event tags if event tags is an object', function() { - assert.isTrue(eventTagsValidator.validate({ testAttribute: 'testValue' })); + assert.isTrue(validate({ testAttribute: 'testValue' })); }); it('should throw an error if event tags is an array', function() { var eventTagsArray = ['notGonnaWork']; assert.throws(function() { - eventTagsValidator.validate(eventTagsArray); + validate(eventTagsArray); }, sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, 'EVENT_TAGS_VALIDATOR')); }); it('should throw an error if event tags is null', function() { assert.throws(function() { - eventTagsValidator.validate(null); + validate(null); }, sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, 'EVENT_TAGS_VALIDATOR')); }); @@ -45,7 +44,7 @@ describe('lib/utils/event_tags_validator', function() { console.log('This is an invalid input!'); } assert.throws(function() { - eventTagsValidator.validate(invalidInput); + validate(invalidInput); }, sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, 'EVENT_TAGS_VALIDATOR')); }); });