UNPKG

@eluvio/elv-js-helpers

Version:

A collection of Javascript helper functions used by several Eluvio libraries.

24 lines (17 loc) 945 B
const TH = require('../../../test-helpers') const assertObjValuesValid = TH.requireSrcFile('ModelAssertion/assertObjValuesValid') describe('assertObjValuesValid', () => { const defBasicModel = TH.requireSrcFile('ModelFactory/defBasicModel') const NonBlankStrModel = TH.requireSrcFile('Model/NonBlankStrModel') it('should work as expected', () => { const NoBlankStringValsObjModel = defBasicModel('NoBlankStringValsObj', Object) .extend() .assert(...assertObjValuesValid(NonBlankStrModel)) TH.expect(()=>NoBlankStringValsObjModel({foo: ' '})).to.throw('key "foo" points to a value that is an invalid NonBlankString (NonBlankString: Value must not be a blank string (got: " "))') const AnyValueModel = defBasicModel('AnyValue', Object) .extend() .assert(...assertObjValuesValid(null)) AnyValueModel({foo: 3}).should.eql( {foo:3}) AnyValueModel({foo: ' '}).should.eql( {foo:' '}) }) })