diff --git a/test/write_grids.test.js b/test/write_grids.test.js index 4d30c1e..affd2a4 100644 --- a/test/write_grids.test.js +++ b/test/write_grids.test.js @@ -30,20 +30,17 @@ exports['test mbtiles file creation'] = function(beforeExit) { // Flip Y coordinate because file names are TMS, but .putGrid() expects XYZ. coords[2] = Math.pow(2, coords[3]) - 1 - coords[2]; - fs.readFile(__dirname + '/fixtures/grids/' + file, 'utf8', function(err, grid) { + var grid = fs.readFileSync(__dirname + '/fixtures/grids/' + file, 'utf8'); + mbtiles.putGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, JSON.parse(grid), function(err) { if (err) throw err; - - mbtiles.putGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, JSON.parse(grid), function(err) { - if (err) throw err; - completed.written++; - if (completed.written === 241) { - mbtiles.stopWriting(function(err) { - completed.stopped = true; - if (err) throw err; - verifyWritten(); - }); - } - }); + completed.written++; + if (completed.written === 241) { + mbtiles.stopWriting(function(err) { + completed.stopped = true; + if (err) throw err; + verifyWritten(); + }); + } }); }