Test background and style

This commit is contained in:
Tom MacWright
2012-12-03 12:21:37 -05:00
parent 1b0c0aeaa3
commit 24422c61e6
4 changed files with 60 additions and 0 deletions
+1
View File
@@ -49,6 +49,7 @@
<!-- include spec files here... -->
<script type="text/javascript" src="spec/util.js"></script>
<script type="text/javascript" src="spec/background.js"></script>
<script type="text/javascript" src="spec/way.js"></script>
<script type="text/javascript" src="spec/map.js"></script>
<script type="text/javascript" src="spec/hash.js"></script>
+6
View File
@@ -12,6 +12,12 @@ describe('Entity', function () {
e = iD.Entity().update({tags: tags});
expect(e.tags).toBe(tags);
});
it("tags the entity as updated", function () {
var tags = {foo: 'bar'},
e = iD.Entity().update({tags: tags});
expect(e._updated).toBe(true);
});
});
describe("#created", function () {
+37
View File
@@ -0,0 +1,37 @@
describe('Background', function() {
var c, d;
beforeEach(function() {
d = d3.select(document.createElement('div'));
c = iD.Background()
.projection(d3.geo.mercator());
d.call(c);
});
afterEach(function() {
d.remove();
});
describe('iD.Background', function() {
it('is instantiated', function() {
expect(c).toBeTruthy();
});
it('#size', function() {
expect(c.size([100, 100])).toEqual(c);
expect(c.size()).toEqual([100,100]);
});
it('#source', function() {
expect(c.source(iD.Background.Bing)).toEqual(c);
expect(c.source()).toEqual(iD.Background.Bing);
});
});
describe('iD.Background.Bing', function() {
it('generates tiles', function() {
expect(iD.Background.Bing([0,0,0])).toEqual('http://ecn.t0.tiles.virtualearth.net/tiles/a.jpeg?g=587&mkt=en-gb&n=z');
});
});
});
+16
View File
@@ -0,0 +1,16 @@
describe('Style', function() {
describe('#waystack', function() {
it('stacks bridges over non-bridges', function() {
var a = { tags: { bridge: 'yes' } },
b = { tags: {} };
expect(iD.Style.waystack(a, b)).toEqual(1);
expect(iD.Style.waystack(b, a)).toEqual(-1);
});
it('stacks layers', function() {
var a = { tags: { layer: 1 } },
b = { tags: { layer: 0 } };
expect(iD.Style.waystack(a, b)).toEqual(1);
expect(iD.Style.waystack(b, a)).toEqual(-1);
});
});
});