Add first batch of tests
This commit is contained in:
19
test/metadata.js
Normal file
19
test/metadata.js
Normal file
@@ -0,0 +1,19 @@
|
||||
describe('Metadata', function() {
|
||||
describe('/index.json', function() {
|
||||
it('is json', function(done) {
|
||||
supertest(app)
|
||||
.get('/index.json')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
});
|
||||
|
||||
it('is non-empty array', function(done) {
|
||||
supertest(app)
|
||||
.get('/index.json')
|
||||
.expect(function(res) {
|
||||
res.body.should.be.Array();
|
||||
res.body.length.should.be.greaterThan(0);
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
20
test/setup.js
Normal file
20
test/setup.js
Normal file
@@ -0,0 +1,20 @@
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
global.should = require('should');
|
||||
global.supertest = require('supertest');
|
||||
|
||||
before(function(done) {
|
||||
console.log('global setup');
|
||||
process.chdir('test_data');
|
||||
var running = require('../src/server')({
|
||||
config: 'config.json',
|
||||
port: 8888
|
||||
}, done);
|
||||
global.app = running.app;
|
||||
global.server = running.server;
|
||||
});
|
||||
|
||||
after(function() {
|
||||
console.log('global teardown');
|
||||
global.server.close(function() { console.log('Done'); });
|
||||
});
|
||||
28
test/tiles_raster.js
Normal file
28
test/tiles_raster.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var testTile = function(prefix, z, x, y, format, status, type) {
|
||||
var path = '/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
||||
it(path + ' returns ' + status, function(done) {
|
||||
var test = supertest(app).get(path);
|
||||
if (status) test.expect(status);
|
||||
if (type) test.expect('Content-Type', type);
|
||||
test.end(done);
|
||||
});
|
||||
};
|
||||
|
||||
describe('Raster tiles', function() {
|
||||
describe('existing tiles', function() {
|
||||
testTile('test', 0, 0, 0, 'png', 200, /image\/png/);
|
||||
testTile('test', 0, 0, 0, 'jpg', 200, /image\/jpeg/);
|
||||
testTile('test', 0, 0, 0, 'jpeg', 200, /image\/jpeg/);
|
||||
testTile('test', 0, 0, 0, 'webp', 200, /image\/webp/);
|
||||
|
||||
testTile('test', 1, 1, 1, 'png', 200);
|
||||
});
|
||||
|
||||
describe('error tiles', function() {
|
||||
testTile('non_existent', 0, 0, 0, 'png', 404);
|
||||
testTile('test', -1, 0, 0, 'png', 404);
|
||||
testTile('test', 0, 1, 0, 'png', 404);
|
||||
testTile('test', 0, 0, 1, 'png', 404);
|
||||
testTile('test', 0, 0, 1, 'gif', 404);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user