diff --git a/lib/model-definition.js b/lib/model-definition.js index 3a75ac08..ae53a1be 100644 --- a/lib/model-definition.js +++ b/lib/model-definition.js @@ -265,7 +265,7 @@ ModelDefinition.prototype.toJSON = function (forceRebuild) { this.json = null; } if (this.json) { - return json; + return this.json; } var json = { name: this.name, diff --git a/test/model-definition.test.js b/test/model-definition.test.js index 562e236e..080685e4 100644 --- a/test/model-definition.test.js +++ b/test/model-definition.test.js @@ -36,7 +36,9 @@ describe('ModelDefinition class', function () { assert.equal(json.properties.approved.type, "Boolean"); assert.equal(json.properties.joinedAt.type, "Date"); assert.equal(json.properties.age.type, "Number"); - + + assert.deepEqual(User.toJSON(), json); + done(); });