Entity specs

This commit is contained in:
John Firebaugh
2012-11-26 21:16:18 -04:00
parent 21ef3e4ce1
commit 447b89fa01
2 changed files with 15 additions and 17 deletions

View File

@@ -48,6 +48,7 @@
<script type="text/javascript" src="spec/Way.js"></script>
<script type="text/javascript" src="spec/Map.js"></script>
<script type="text/javascript" src="spec/Graph.js"></script>
<script type="text/javascript" src="spec/Entity.js"></script>
<script type="text/javascript" src="spec/Connection.js"></script>
<script type="text/javascript" src="spec/GeoJSON.js"></script>
<script type="text/javascript" src="spec/XML.js"></script>

View File

@@ -1,23 +1,20 @@
describe('Entity', function () {
var entity;
beforeEach(function () {
entity = new iD.Entity();
});
describe('#parentWays', function () {
it('returns an array of parents with entityType way', function () {
entity.addParent({_id: 1, type: 'way'});
entity.addParent({_id: 2, type: 'node'});
expect(entity.parentWays()).toEqual([{_id: 1, type: 'way'}]);
describe("#update", function () {
it("returns a new Entity", function () {
var a = iD.Entity(),
b = a.update({});
expect(b instanceof iD.Entity).toBeTruthy();
expect(a).not.toBe(b);
});
});
describe('#parentRelations', function () {
it('returns an array of parents with entityType relation', function () {
entity.addParent({_id: 1, type: 'way'});
entity.addParent({_id: 2, type: 'relation'});
expect(entity.parentRelations()).toEqual([{_id: 2, type: 'relation'}]);
it("updates the specified attributes", function () {
var tags = {foo: 'bar'},
e = iD.Entity().update({tags: tags});
expect(e.tags).toBe(tags);
});
it("returns a modified Entity", function () {
expect(iD.Entity().update({}).modified).toBeTruthy();
});
});
});