Code coverage report for ReactFlux/lib/configs.js

Statements: 100% (24 / 24)      Branches: 100% (16 / 16)      Functions: 100% (6 / 6)      Lines: 100% (24 / 24)      Ignored: none     

All files » ReactFlux/lib/ » configs.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 821   1 1 1 1   1                   1                     3 2   1             3 2   1             3 2   1             3 2   1             1 1 1 1       3            
var _isString = require('lodash-node/modern/lang/isString');
 
var CONSTANTS_DEFAULT_SEPARATOR = '_';
var CONSTANTS_DEFAULT_SUCCESS_SUFFIX = 'SUCCESS';
var CONSTANTS_DEFAULT_FAIL_SUFFIX = 'FAIL';
var CONSTANTS_DEFAULT_AFTER_SUFFIX = 'AFTER';
 
var CONFIGS = {
	constants: {
		separator: CONSTANTS_DEFAULT_SEPARATOR,
		successSuffix: CONSTANTS_DEFAULT_SUCCESS_SUFFIX,
		failSuffix: CONSTANTS_DEFAULT_FAIL_SUFFIX,
		afterSuffix: CONSTANTS_DEFAULT_AFTER_SUFFIX
 
	}
};
 
module.exports = {
 
	/**
	 * constants
	 */
	constants: {
 
		/**
		 * @param {string} separator
		 */
		setSeparator: function (separator) {
			if (!_isString(separator) || !separator.length) {
				throw new Error('Constants.separator must be a non empty string');
			}
			CONFIGS.constants.separator = separator;
		},
 
		/**
		 * @param {string} suffix
		 */
		setSuccessSuffix: function (suffix) {
			if (!_isString(suffix) || !suffix.length) {
				throw new Error('Constants.successSuffix must be a non empty string');
			}
			CONFIGS.constants.successSuffix = suffix;
		},
 
		/**
		 * @param {string} suffix
		 */
		setFailSuffix: function (suffix) {
			if (!_isString(suffix) || !suffix.length) {
				throw new Error('Constants.failSuffix must be a non empty string');
			}
			CONFIGS.constants.failSuffix = suffix;
		},
 
		/**
		 * @param {string} suffix
		 */
		setAfterSuffix: function (suffix) {
			if (!_isString(suffix) || !suffix.length) {
				throw new Error('Constants.afterSuffix must be a non empty string');
			}
			CONFIGS.constants.afterSuffix = suffix;
		},
 
		/**
		 *
		 */
		resetToDefaults: function () {
			CONFIGS.constants.separator = CONSTANTS_DEFAULT_SEPARATOR;
			CONFIGS.constants.successSuffix = CONSTANTS_DEFAULT_SUCCESS_SUFFIX;
			CONFIGS.constants.failSuffix = CONSTANTS_DEFAULT_FAIL_SUFFIX;
			CONFIGS.constants.afterSuffix = CONSTANTS_DEFAULT_AFTER_SUFFIX;
		},
 
		get: function () {
			return CONFIGS.constants;
		}
 
	}
 
};