[bug] TypeImpl.getInitialmodel should always return a fresh (ie. cloned) model. #316

This commit is contained in:
Henry 2015-11-17 14:30:34 -08:00
parent 2b2ac0b0d9
commit 606667eb4d
2 changed files with 5 additions and 1 deletions

View File

@ -157,7 +157,7 @@ define(
};
TypeImpl.prototype.getInitialModel = function () {
return this.typeDef.model || {};
return JSON.parse(JSON.stringify(this.typeDef.model || {}));
};
TypeImpl.prototype.getDefinition = function () {

View File

@ -101,6 +101,10 @@ define(
expect(type.getInitialModel().someKey).toEqual("some value");
});
it("provides a fresh initial model each time", function () {
expect(type.getInitialModel().someKey).toEqual("some value");
});
it("provides type properties", function () {
expect(type.getProperties().length).toEqual(1);
});