mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 15:56:56 +02:00
Get internal ID logic in one place
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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({});
|
||||
|
||||
Reference in New Issue
Block a user