Jasmine tests for ol.TileCoord

This commit is contained in:
Éric Lemoine
2012-09-24 22:56:40 +02:00
parent 2aac0140c1
commit c2901dec73
2 changed files with 49 additions and 0 deletions

View File

@@ -76,6 +76,7 @@
<!-- include spec files here... -->
<script type="text/javascript" src="spec/ol/object.test.js"></script>
<script type="text/javascript" src="spec/ol/tilecoord.test.js"></script>
<script type="text/javascript">
(function() {

View File

@@ -0,0 +1,48 @@
goog.require('ol.TileCoord');
describe('ol.TileCoord', function() {
describe('create', function() {
it('sets x y z properties as expected', function() {
var tc = new ol.TileCoord(1, 2, 3);
expect(tc.z).toEqual(1);
expect(tc.x).toEqual(2);
expect(tc.y).toEqual(3);
});
});
describe('create from quad key', function() {
it('sets x y z properties as expected', function() {
var tc = ol.TileCoord.createFromQuadKey('213');
expect(tc.z).toEqual(3);
expect(tc.x).toEqual(3);
expect(tc.y).toEqual(5);
});
});
describe('create from string', function() {
it('sets x y z properties as expected', function() {
var str = '1/2/3';
var tc = ol.TileCoord.createFromString(str);
expect(tc.z).toEqual(1);
expect(tc.x).toEqual(2);
expect(tc.y).toEqual(3);
});
});
describe('call quadKey', function() {
it('returns expected string', function() {
var tc = new ol.TileCoord(3, 3, 5);
var s = tc.quadKey();
expect(s).toEqual('213');
});
});
describe('hash', function() {
it('produces different hashes for different tile coords', function() {
var tc1 = new ol.TileCoord(3, 2, 1);
var tc2 = new ol.TileCoord(3, 1, 1);
expect(tc1.hash()).not.toEqual(tc2.hash());
});
});
});