Permalink
Browse files

complex object basic test

  • Loading branch information...
aaronpowell committed Nov 24, 2011
1 parent ec66356 commit 761ac70d35805b79e59f38b8d9e90746b49332db
Showing with 21 additions and 2 deletions.
  1. +9 −2 lib/tbd.js
  2. +12 −0 tests/complex-property-spec.js
View
@@ -1,12 +1,19 @@
(function (undefined) {
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __hasOwnProp = Object.prototype.hasOwnProperty,
tbd;
function ValueBuilder(def, builder) {
var value = def,
self = this;
this.build = function () {
if (typeof value === 'function') {
return value();
} else if (typeof value === 'object' && value) {
if(value.constructor === Array) {
return value.slice();
}
return tbd.from(value).make(1)[0];
}
return value;
};
@@ -64,7 +71,7 @@
};
}
this.tbd = {
tbd = this.tbd = {
from: function (schema) {
return new ObjectBuilder(schema);
}
@@ -0,0 +1,12 @@
describe('tbd-complex-properties', function() {
var tbd = require('../lib/');
it('should clone complex properties', function() {
var data = tbd.from({
foo: {
bar: 'baz'
}
}).make(2);
expect(data[0].foo).not.toBe(data[1].foo);
});
});

0 comments on commit 761ac70

Please sign in to comment.