/** * Validates that the keys required for basic message creation are set on * the target object and that each key's value is of the correct type. * @function validateCreateManifest * @returns {Boolean} - returns a boolean indicating whether or not the * instances required keys are correctly set for creation payload export */ validateCreateManifest () { return every(pick(this, REQUIRED_MSG_CREATE_EXPORT_KEYS), isString); }
const allBlanks = o => { if(isString(o) === false) { return false; } return emptyString(o) ? false : every(blankString, o.split('')) }
it('should implement a generator', () => { s.def('::ingredient2', s.cat(':quantity', isInteger, ':unit', isString)); expect(s.exercise('::ingredient2', 7)).to.have.length(7) .to.satisfy(sample => every(sample, ([[v1, v2]]) => isInteger(v1) || isString(v2))); });
function isEqualProps(currentProps, nextProps) { var haveSameKeys = isEqual( keys(currentProps).sort(), keys(nextProps).sort() ); if (!haveSameKeys) { return false; } return every(keys(currentProps), (k) => isEqualValue(currentProps[k], nextProps[k])); }
function check(sym, opts = {}) { const {args: argsSpec, ret: returnSpec = alwaysTrue, fn: funcSpec = alwaysTrue} = fdef.specs(sym); const samples = exerciseFn(sym); const validReturnValue = ([, returnValue]) => isValid(returnSpec, returnValue); const validateFunction = ([args, returnValue]) => funcSpec({ret: returnValue, args: conform(argsSpec, args)}); const pass = every(samples, sample => validReturnValue(sample) && validateFunction(sample)); return { spec: {}, sym: sym.name, result: pass, type: ':pass' }; }
describe('Test the exercise function', () => { it('should generate 10 integers', () => { expect(s.exercise(isInteger)).to.have.length(10); }); it('should generate 10 booleans', () => { expect(s.exercise(isBoolean)).to.have.length(10).to.satisfy(sample => every(sample, ([b]) => isBoolean(b))); }); it('should generate 5 random values from a set', () => { s.def('::color', ['Red', 'Blue', 'Dun']); expect(s.exercise('::color', 5)).to.have.length(5); }); it('should generate 7 random values from a named spec', () => { s.def('::pairs', s.cat(':n', isInteger, ':s', isString)); expect(s.exercise('::pairs', 7)).to.have.length(7).to.satisfy(sample => every(sample, ([[n, s]]) => isInteger(n) && isString(s))); }); it('should generate 10 random values from a spec object', () => { expect(s.exercise(s.nilable(isString))).to.have.length(10).to.satisfy(sample => every(sample, ([s]) => isNull(s) || isString(s))); }); it('should throw an exception', () => { s.def('::impossible', s.and(isInteger, isString)); expect(() => s.exercise('::impossible')).to.throw(Error, /sampleFromSpec failed.*/); }); });
t.deepEqual(set.getCreateResponse().responses.length, 2, 'There should be two create response objects in the responses array'); t.true(every(set.getCreateResponse().responses, {status: 'success'}), 'Every status property in responses array should be set to "success"'); t.deepEqual(set.getCreateResponse().status, 200,
this.isAppMindInitiated = every([ this.appServerMindInitializersInvoked, this.appRoutingMindInitiated,
.to.satisfy(sample => every(sample, ([v]) => isInteger(v) && isEven(v))); });
.to.satisfy(sample => every(sample, ([v]) => isInteger(v) || isString(v))); }); });
/** * Validates that the keys required for message update are set on the target * object and that each key's value is of the correct type. * @function validateUpdateManifest * @returns {Boolean} - returns a boolean indicating whether or not the * instances required keys are correctly set for the update payload export */ validateUpdateManifest () { return every(pick(this, REQUIRED_MSG_UPDATE_EXPORT_KEYS), isString); }
this.isAppMindInitiated = every([ this.appServerMindInitializersInvoked, this.appRoutingMindInitiated,