@eluvio/elv-js-helpers
Version:
A collection of Javascript helper functions used by several Eluvio libraries.
24 lines (20 loc) • 1.03 kB
JavaScript
const TH = require('../../../test-helpers')
const defObjectModel = TH.requireSrcFile('ModelFactory/defObjectModel')
describe('defObjectModel', () => {
it('should work as expected', () => {
const PersonNameModel = defObjectModel('PersonName', {first: String, last: String})
TH.expect(() => PersonNameModel(-1)).to.throw('expecting Object, got Number -1')
TH.expect(() => PersonNameModel(-1)).to.not.throw('expecting first to be String, got undefined')
TH.expect(() => PersonNameModel(null)).to.throw('expecting Object, got null')
TH.expect(() => PersonNameModel(null)).to.not.throw('expecting first to be String, got undefined')
PersonNameModel({first: 'Arthur', last: 'Dent'}).should.eql({first: 'Arthur', last: 'Dent'})
TH.expect(() => PersonNameModel({first: 'Arthur'})).to.throw('expecting last to be String, got undefined')
PersonNameModel({first: 'A', last: 'D', species: 'human'}).should.eql(
{
first: 'A',
last: 'D',
species: 'human'
}
)
})
})