-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.test.js
97 lines (76 loc) · 2.43 KB
/
app.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict'
require("dotenv").config
const { test } = require('tap')
const build = require('./src/app');
const fs = require("fs");
const path = require("path");
const TILESDIR = process.env.TILESDIR || "./src/tilesets";
const files = fs.readdirSync(TILESDIR);
const dbFiles = files.filter(f => [".mbtiles", ".sqlite"].indexOf(path.extname(f)) > -1)
const KEYS = (fs.existsSync("./keys.json")) ? require("./keys.json") : null;
//TEST THE INDEX HOMEPAGE ROUTE
test('requests the "/" route', async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: '/'
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
//TEST THE STATIC ROUTE
test('requests the "/style.css" route', async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: '/style.css'
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
//TEST THE WMTS ROUTE - FAILING!
test('requests the "/WMTS" route', async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: '/WMTS/1.0.0'
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
//TEST THE TILEJSON ROUTE FOR EACH ROUTE
dbFiles.forEach(f => {
test(`requests the ${path.basename(f)}/tilejson route`, async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: `${path.basename(f)}/tilejson`
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
});
//TEST THE WMTS XML ROUTE FOR EACH ROUTE
dbFiles.forEach(f => {
test(`requests the ${path.basename(f)}/WMTS/1.0.0/WMTSCapabilities.xml route`, async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: `${path.basename(f)}/WMTS/1.0.0/WMTSCapabilities.xml`
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
});
//TEST THE MAP ROUTE FOR EACH ROUTE
dbFiles.forEach(f => {
test(`requests the ${path.basename(f)}/map route`, async t => {
const app = build()
t.teardown(() => app.close())
const response = await app.inject({
method: 'GET',
url: `${path.basename(f)}/map`
})
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
});