datapumps
Version:
Node.js ETL (Extract, Transform, Load) toolkit for easy data import, export or transfer between systems.
62 lines (56 loc) • 1.96 kB
JavaScript
(function() {
var ObjectTransformMixin, sinon;
require('should');
sinon = require('sinon');
ObjectTransformMixin = require('../ObjectTransformMixin');
describe('ObjectTransformMixin()', function() {
var mixin, target;
target = {};
mixin = ObjectTransformMixin();
mixin(target);
describe('#propertiesToLowerCase()', function() {
return it('should lowercase property names', function() {
return target.propertiesToLowerCase({
TEST: 'value'
}).should.eql({
test: 'value'
});
});
});
describe('#requireProperty()', function() {
it('should throw error when property is missing', function() {
return (function() {
return target.requireProperty({}, 'test');
}).should["throw"]('Missing property: test');
});
it('should return property value if property exists', function() {
return target.requireProperty({
test: 'value'
}, 'test').should.equal('value');
});
return it('should return property values if multiple property checked', function() {
var obj;
obj = {
test: 'value',
foo: 'bar',
misc: false
};
return target.requireProperty(obj, ['test', 'misc']).should.eql({
test: 'value',
misc: false
});
});
});
return describe('#boolValueOf()', function() {
return it('should return false for "off", "false", "no", false, null or undefined', function() {
target.boolValueOf('off').should.eql(false);
target.boolValueOf('false').should.eql(false);
target.boolValueOf('no').should.eql(false);
target.boolValueOf(false).should.eql(false);
target.boolValueOf(null).should.eql(false);
target.boolValueOf(void 0).should.eql(false);
return target.boolValueOf('anyOtherValue').should.eql(true);
});
});
});
}).call(this);