Convert to esm module syntax (#606)
* switch to esm module * Update package.json * change to maplibre package * fix tests * eslint * remove extra package updates * Delete package-lock.json * change 'fs' to 'node:fs' * put back node 10. without the package updates this still works * remove trailing commas * remove unassociated fix / formatting * remove unassociated fix * remove eslint from this PR * remove unassociated fix * lint * Merge remote-tracking branch 'upstream/master' into esm_update * fix mlgl * update maplibre-native to new version with arm64 * update minor version
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
var testTileJSONArray = function(url) {
|
||||
const testTileJSONArray = function(url) {
|
||||
describe(url + ' is array of TileJSONs', function() {
|
||||
it('is json', function(done) {
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
.get(url)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
});
|
||||
|
||||
it('is non-empty array', function(done) {
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(function(res) {
|
||||
res.body.should.be.Array();
|
||||
res.body.length.should.be.greaterThan(0);
|
||||
}).end(done);
|
||||
.get(url)
|
||||
.expect(function(res) {
|
||||
expect(res.body).to.be.a('array');
|
||||
expect(res.body.length).to.be.greaterThan(0);
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var testTileJSON = function(url) {
|
||||
const testTileJSON = function(url) {
|
||||
describe(url + ' is TileJSON', function() {
|
||||
it('is json', function(done) {
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
.get(url)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
});
|
||||
|
||||
it('has valid tiles', function(done) {
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(function(res) {
|
||||
res.body.tiles.length.should.be.greaterThan(0);
|
||||
}).end(done);
|
||||
.get(url)
|
||||
.expect(function(res) {
|
||||
expect(res.body.tiles.length).to.be.greaterThan(0);
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -41,8 +41,8 @@ describe('Metadata', function() {
|
||||
describe('/health', function() {
|
||||
it('returns 200', function(done) {
|
||||
supertest(app)
|
||||
.get('/health')
|
||||
.expect(200, done);
|
||||
.get('/health')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,21 +53,21 @@ describe('Metadata', function() {
|
||||
describe('/styles.json is valid array', function() {
|
||||
it('is json', function(done) {
|
||||
supertest(app)
|
||||
.get('/styles.json')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
.get('/styles.json')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/, done);
|
||||
});
|
||||
|
||||
it('contains valid item', function(done) {
|
||||
supertest(app)
|
||||
.get('/styles.json')
|
||||
.expect(function(res) {
|
||||
res.body.should.be.Array();
|
||||
res.body.length.should.be.greaterThan(0);
|
||||
res.body[0].version.should.equal(8);
|
||||
res.body[0].id.should.be.String();
|
||||
res.body[0].name.should.be.String();
|
||||
}).end(done);
|
||||
.get('/styles.json')
|
||||
.expect(function(res) {
|
||||
expect(res.body).to.be.a('array');
|
||||
expect(res.body.length).to.be.greaterThan(0);
|
||||
expect(res.body[0].version).to.be.equal(8);
|
||||
expect(res.body[0].id).to.be.a('string');
|
||||
expect(res.body[0].name).to.be.a('string');
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
global.should = require('should');
|
||||
global.supertest = require('supertest');
|
||||
import {expect} from 'chai';
|
||||
import supertest from 'supertest';
|
||||
import {server} from '../src/server.js';
|
||||
|
||||
require = require('esm')(module);
|
||||
global.expect = expect;
|
||||
global.supertest = supertest;
|
||||
|
||||
before(function() {
|
||||
console.log('global setup');
|
||||
process.chdir('test_data');
|
||||
var running = require('../src/server')({
|
||||
const running = server({
|
||||
configPath: 'config.json',
|
||||
port: 8888,
|
||||
publicUrl: '/test/'
|
||||
@@ -20,5 +22,7 @@ before(function() {
|
||||
|
||||
after(function() {
|
||||
console.log('global teardown');
|
||||
global.server.close(function() { console.log('Done'); process.exit(); });
|
||||
global.server.close(function() {
|
||||
console.log('Done'); process.exit();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
var testStatic = function(prefix, q, format, status, scale, type, query) {
|
||||
const testStatic = function(prefix, q, format, status, scale, type, query) {
|
||||
if (scale) q += '@' + scale + 'x';
|
||||
var path = '/styles/' + prefix + '/static/' + q + '.' + format;
|
||||
let path = '/styles/' + prefix + '/static/' + q + '.' + format;
|
||||
if (query) {
|
||||
path += query;
|
||||
}
|
||||
it(path + ' returns ' + status, function(done) {
|
||||
var test = supertest(app).get(path);
|
||||
const test = supertest(app).get(path);
|
||||
if (status) test.expect(status);
|
||||
if (type) test.expect('Content-Type', type);
|
||||
test.end(done);
|
||||
});
|
||||
};
|
||||
|
||||
var prefix = 'test-style';
|
||||
const prefix = 'test-style';
|
||||
|
||||
describe('Static endpoints', function() {
|
||||
describe('center-based', function() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
var testIs = function(url, type, status) {
|
||||
const testIs = function(url, type, status) {
|
||||
it(url + ' return ' + (status || 200) + ' and is ' + type.toString(),
|
||||
function(done) {
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(status || 200)
|
||||
.expect('Content-Type', type, done);
|
||||
});
|
||||
supertest(app)
|
||||
.get(url)
|
||||
.expect(status || 200)
|
||||
.expect('Content-Type', type, done);
|
||||
});
|
||||
};
|
||||
|
||||
var prefix = 'test-style';
|
||||
const prefix = 'test-style';
|
||||
|
||||
describe('Styles', function() {
|
||||
describe('/styles/' + prefix + '/style.json is valid style', function() {
|
||||
@@ -16,16 +16,16 @@ describe('Styles', function() {
|
||||
|
||||
it('contains expected properties', function(done) {
|
||||
supertest(app)
|
||||
.get('/styles/' + prefix + '/style.json')
|
||||
.expect(function(res) {
|
||||
res.body.version.should.equal(8);
|
||||
res.body.name.should.be.String();
|
||||
res.body.sources.should.be.Object();
|
||||
res.body.glyphs.should.be.String();
|
||||
res.body.sprite.should.be.String();
|
||||
res.body.sprite.should.equal('/test/styles/test-style/sprite');
|
||||
res.body.layers.should.be.Array();
|
||||
}).end(done);
|
||||
.get('/styles/' + prefix + '/style.json')
|
||||
.expect(function(res) {
|
||||
expect(res.body.version).to.be.equal(8);
|
||||
expect(res.body.name).to.be.a('string');
|
||||
expect(res.body.sources).to.be.a('object');
|
||||
expect(res.body.glyphs).to.be.a('string');
|
||||
expect(res.body.sprite).to.be.a('string');
|
||||
expect(res.body.sprite).to.be.equal('/test/styles/test-style/sprite');
|
||||
expect(res.body.layers).to.be.a('array');
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
describe('/styles/streets/style.json is not served', function() {
|
||||
@@ -44,7 +44,7 @@ describe('Fonts', function() {
|
||||
testIs('/fonts/Open Sans Bold/0-255.pbf', /application\/x-protobuf/);
|
||||
testIs('/fonts/Open Sans Regular/65280-65535.pbf', /application\/x-protobuf/);
|
||||
testIs('/fonts/Open Sans Bold,Open Sans Regular/0-255.pbf',
|
||||
/application\/x-protobuf/);
|
||||
/application\/x-protobuf/);
|
||||
testIs('/fonts/Nonsense,Open Sans Bold/0-255.pbf', /./, 400);
|
||||
|
||||
testIs('/fonts/Nonsense/0-255.pbf', /./, 400);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
var testTile = function(prefix, z, x, y, status) {
|
||||
var path = '/data/' + prefix + '/' + z + '/' + x + '/' + y + '.pbf';
|
||||
const testTile = function(prefix, z, x, y, status) {
|
||||
const path = '/data/' + prefix + '/' + z + '/' + x + '/' + y + '.pbf';
|
||||
it(path + ' returns ' + status, function(done) {
|
||||
var test = supertest(app).get(path);
|
||||
const test = supertest(app).get(path);
|
||||
if (status) test.expect(status);
|
||||
if (status == 200) test.expect('Content-Type', /application\/x-protobuf/);
|
||||
test.end(done);
|
||||
});
|
||||
};
|
||||
|
||||
var prefix = 'openmaptiles';
|
||||
const prefix = 'openmaptiles';
|
||||
|
||||
describe('Vector tiles', function() {
|
||||
describe('existing tiles', function() {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
var testTile = function(prefix, z, x, y, format, status, scale, type) {
|
||||
const testTile = function(prefix, z, x, y, format, status, scale, type) {
|
||||
if (scale) y += '@' + scale + 'x';
|
||||
var path = '/styles/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
||||
const path = '/styles/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
||||
it(path + ' returns ' + status, function(done) {
|
||||
var test = supertest(app).get(path);
|
||||
const test = supertest(app).get(path);
|
||||
test.expect(status);
|
||||
if (type) test.expect('Content-Type', type);
|
||||
test.end(done);
|
||||
});
|
||||
};
|
||||
|
||||
var prefix = 'test-style';
|
||||
const prefix = 'test-style';
|
||||
|
||||
describe('Raster tiles', function() {
|
||||
describe('valid requests', function() {
|
||||
@@ -41,6 +41,6 @@ describe('Raster tiles', function() {
|
||||
testTile(prefix, 0, 0, 0, 'png', 404, 1);
|
||||
testTile(prefix, 0, 0, 0, 'png', 404, 5);
|
||||
|
||||
//testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this
|
||||
// testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user