forked from ghettovoice/ol-tilecache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
40 lines (33 loc) · 1.48 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Unit tests
*
* @package ol3-tilecache
* @author Vladimir Vershinin <[email protected]>
*/
var assert = chai.assert;
var urlTemplate = 'http://{a-c}.tileserver.org/{0z}/{x1}/{x2}/{x3}/{y1}/{y2}/{y3}.png';
var flipUrlTemplate = 'http://{a-c}.tileserver.org/{0z}/{x1}/{x2}/{x3}/{-y1}/{-y2}/{-y3}.png';
var tiles = [
[ [ 5, 160, -10 ], 'http://b.tileserver.org/05/000/000/160/000/000/009.png', 'http://b.tileserver.org/05/000/000/160/000/000/022.png' ],
[ [ 18, 6053278, -15687 ], 'http://b.tileserver.org/18/006/053/278/000/015/686.png', 'http://b.tileserver.org/18/006/053/278/000/246/457.png' ],
[ [ 10, 10907, -826 ], 'http://b.tileserver.org/10/000/010/907/000/000/825.png', 'http://b.tileserver.org/10/000/010/907/000/000/198.png' ],
];
suite('ol3-tilecache tests', function () {
test('Test URL template ' + urlTemplate, function () {
var tileUrlFunction = ol.TileCacheUrlFunction.createTileUrlFunction(urlTemplate);
var tileUrl;
assert.typeOf(tileUrlFunction, 'function');
tiles.map(function (arr) {
tileUrl = tileUrlFunction(arr[ 0 ]);
assert.equal(tileUrl, arr[ 1 ]);
});
});
test('Test URL template ' + flipUrlTemplate, function () {
var tileUrlFunction = ol.TileCacheUrlFunction.createTileUrlFunction(flipUrlTemplate);
var tileUrl;
tiles.map(function (arr) {
tileUrl = tileUrlFunction(arr[ 0 ]);
assert.equal(tileUrl, arr[ 2 ]);
});
});
});