node-fit-model
Version:
Checks whether an object is fits into a model.
46 lines (32 loc) • 1.14 kB
JavaScript
;
/**
* Represents a test for "reqiured" part of the modelling
*
*
*/
var expect = require('chai').expect,
fs = require('fs'),
options = {
modelDir: __dirname + '/data',
postFix: 'Model.js'
},
fitModel = require('./../index'),
modelling = new fitModel(options),
data = require('./TestObject');
describe('Require Parameters', function () {
it('should throw if a required parameter (profile_id) is not existant', function () {
var copy = JSON.parse(JSON.stringify(data));
delete copy.profile_id;
expect(function(){
modelling.fitModel('User', copy);
}).to.throw("Value of profile_id is required. Actual => undefined");
});
it('should not throw if a required parameter is set', function () {
expect(modelling.fitModel('User', data)).to.equal(true);
});
it('should not throw if parameter exists and the value can be null', function(){
var copy = JSON.parse(JSON.stringify(data));
copy.timezone_offset = null;
expect(modelling.fitModel('User', copy)).to.equal(true);
});
});