From 0e2889d5d6c4e1b2511b2b011e1854d61979d7ca Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 6 Dec 2012 14:20:02 -0500 Subject: [PATCH] Add freezing specs --- test/spec/graph/entity.js | 26 ++++++++++++++++++++++++++ test/spec/graph/graph.js | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/spec/graph/entity.js b/test/spec/graph/entity.js index 0273ee4c6..7b15a4788 100644 --- a/test/spec/graph/entity.js +++ b/test/spec/graph/entity.js @@ -1,4 +1,18 @@ describe('Entity', function () { + if (iD.debug) { + it("is frozen", function () { + expect(Object.isFrozen(iD.Entity())).to.be.true; + }); + + it("freezes tags", function () { + expect(Object.isFrozen(iD.Entity().tags)).to.be.true; + }); + + it("does not freeze transients", function () { + expect(Object.isFrozen(iD.Entity().transients)).to.be.false; + }); + } + describe("#update", function () { it("returns a new Entity", function () { var a = iD.Entity(), @@ -125,6 +139,12 @@ describe('Node', function () { }); describe('Way', function () { + if (iD.debug) { + it("freezes nodes", function () { + expect(Object.isFrozen(iD.Way().nodes)).to.be.true; + }); + } + it("returns a way", function () { expect(iD.Way().type).to.equal("way"); }); @@ -172,6 +192,12 @@ describe('Way', function () { }); describe('Relation', function () { + if (iD.debug) { + it("freezes nodes", function () { + expect(Object.isFrozen(iD.Relation().members)).to.be.true; + }); + } + it("returns a relation", function () { expect(iD.Relation().type).to.equal("relation"); }); diff --git a/test/spec/graph/graph.js b/test/spec/graph/graph.js index 31ef038b9..16cbf6995 100644 --- a/test/spec/graph/graph.js +++ b/test/spec/graph/graph.js @@ -16,6 +16,16 @@ describe('iD.Graph', function() { expect(graph.annotation).to.equal('first graph'); }); + if (iD.debug) { + it("is frozen", function () { + expect(Object.isFrozen(iD.Graph())).to.be.true; + }); + + it("freezes entities", function () { + expect(Object.isFrozen(iD.Graph().entities)).to.be.true; + }); + } + describe('operations', function() { it('#remove', function() { var entities = { 'n-1': {