fix tests
This commit is contained in:
@@ -56,6 +56,8 @@ exports['get tiles'] = function(beforeExit) {
|
||||
fs.readdirSync(__dirname + '/fixtures/images/').forEach(function(file) {
|
||||
var coords = file.match(/^plain_1_(\d+)_(\d+)_(\d+).png$/);
|
||||
if (coords) {
|
||||
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
|
||||
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2];
|
||||
mbtiles.getTile(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, tile) {
|
||||
if (err) throw err;
|
||||
assert.deepEqual(tile, fs.readFileSync(__dirname + '/fixtures/images/' + file));
|
||||
@@ -66,11 +68,11 @@ exports['get tiles'] = function(beforeExit) {
|
||||
|
||||
mbtiles.getTile(0, 1, 0, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(-1, 0, 0, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(0, 0, -1, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(3, 1, 8, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(2, -3, 0, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(18, 2, 3, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(4, 0, 0, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(0, 0, 1, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(3, 1, -1, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(2, -3, 3, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(18, 2, 262140, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
mbtiles.getTile(4, 0, 15, yieldsError(status, 'error', 'Tile does not exist'));
|
||||
|
||||
beforeExit(function() {
|
||||
assert.equal(status.success, 285);
|
||||
@@ -88,6 +90,8 @@ exports['get grids'] = function(beforeExit) {
|
||||
fs.readdirSync(__dirname + '/fixtures/grids/').forEach(function(file) {
|
||||
var coords = file.match(/^plain_2_(\d+)_(\d+)_(\d+).json$/);
|
||||
if (coords) {
|
||||
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
|
||||
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2];
|
||||
mbtiles.getGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, grid) {
|
||||
if (err) throw err;
|
||||
assert.deepEqual(JSON.stringify(grid), fs.readFileSync(__dirname + '/fixtures/grids/' + file, 'utf8'));
|
||||
@@ -98,23 +102,15 @@ exports['get grids'] = function(beforeExit) {
|
||||
|
||||
mbtiles.getGrid(0, 1, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(-1, 0, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(0, 0, -1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(3, 1, 8, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(2, -3, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(18, 2, 3, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(4, 0, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
|
||||
mbtiles.getGrid(4, 3, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 4, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 5, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 13, 4, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 0, 14, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(3, 0, 7, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(3, 6, 2, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(0, 0, 1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(3, 1, -1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(2, -3, 3, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(18, 2, 262140, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(4, 0, 15, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
|
||||
beforeExit(function() {
|
||||
assert.equal(status.success, 241);
|
||||
assert.equal(status.error, 14);
|
||||
assert.equal(status.error, 7);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -157,6 +153,8 @@ exports['get grids with different schema'] = function(beforeExit) {
|
||||
fs.readdirSync(__dirname + '/fixtures/grids/').forEach(function(file) {
|
||||
var coords = file.match(/^plain_2_(\d+)_(\d+)_(\d+).json$/);
|
||||
if (coords) {
|
||||
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
|
||||
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2];
|
||||
mbtiles.getGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, grid) {
|
||||
if (err) throw err;
|
||||
assert.deepEqual(JSON.stringify(grid), fs.readFileSync(__dirname + '/fixtures/grids/' + file, 'utf8'));
|
||||
@@ -167,23 +165,15 @@ exports['get grids with different schema'] = function(beforeExit) {
|
||||
|
||||
mbtiles.getGrid(0, 1, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(-1, 0, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(0, 0, -1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(3, 1, 8, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(2, -3, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(18, 2, 3, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(4, 0, 0, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
|
||||
mbtiles.getGrid(4, 3, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 4, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 5, 8, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 13, 4, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(4, 0, 14, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(3, 0, 7, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(3, 6, 2, yieldsError(status, 'error', 'Grid is invalid'));
|
||||
mbtiles.getGrid(0, 0, 1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(3, 1, -1, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(2, -3, 3, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(18, 2, 262140, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
mbtiles.getGrid(4, 0, 15, yieldsError(status, 'error', 'Grid does not exist'));
|
||||
|
||||
beforeExit(function() {
|
||||
assert.equal(status.success, 241);
|
||||
assert.equal(status.error, 14);
|
||||
assert.equal(status.error, 7);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user