Get internal ID logic in one place

This commit is contained in:
John Firebaugh
2012-12-07 07:42:03 -05:00
parent 23856cc1c5
commit 7eec007740
7 changed files with 47 additions and 30 deletions
+22 -4
View File
@@ -1,4 +1,4 @@
describe('Entity', function () {
describe('iD.Entity', function () {
if (iD.debug) {
it("is frozen", function () {
expect(Object.isFrozen(iD.Entity())).to.be.true;
@@ -13,6 +13,24 @@ describe('Entity', function () {
});
}
describe(".id", function () {
it("generates unique IDs", function () {
expect(iD.Entity.id('node')).not.to.equal(iD.Entity.id('node'));
});
describe(".fromOSM", function () {
it("returns a ID string unique across entity types", function () {
expect(iD.Entity.id.fromOSM('node', 1)).to.equal("n1");
});
});
describe(".toOSM", function () {
it("reverses fromOSM", function () {
expect(iD.Entity.id.toOSM(iD.Entity.id.fromOSM('node', 1))).to.equal(1);
});
});
});
describe("#update", function () {
it("returns a new Entity", function () {
var a = iD.Entity(),
@@ -105,7 +123,7 @@ describe('Entity', function () {
});
});
describe('Node', function () {
describe('iD.Node', function () {
it("returns a node", function () {
expect(iD.Node().type).to.equal("node");
});
@@ -138,7 +156,7 @@ describe('Node', function () {
});
});
describe('Way', function () {
describe('iD.Way', function () {
if (iD.debug) {
it("freezes nodes", function () {
expect(Object.isFrozen(iD.Way().nodes)).to.be.true;
@@ -191,7 +209,7 @@ describe('Way', function () {
});
});
describe('Relation', function () {
describe('iD.Relation', function () {
if (iD.debug) {
it("freezes nodes", function () {
expect(Object.isFrozen(iD.Relation().members)).to.be.true;
-10
View File
@@ -1,16 +1,6 @@
describe('Util', function() {
var util;
it('#id', function() {
var a = iD.util.id(),
b = iD.util.id(),
c = iD.util.id(),
d = iD.util.id();
expect(a === b).to.equal(false);
expect(b === c).to.equal(false);
expect(c === d).to.equal(false);
});
it('#trueObj', function() {
expect(iD.util.trueObj(['a', 'b', 'c'])).to.eql({ a: true, b: true, c: true });
expect(iD.util.trueObj([])).to.eql({});