2021-04-30 15:31:54 +02:00
|
|
|
import { setupAppWithBaseUrl } from '../helpers/test-helper';
|
|
|
|
|
|
|
|
import dbInit from '../helpers/database-init';
|
|
|
|
|
|
|
|
let db;
|
2021-05-28 11:10:24 +02:00
|
|
|
let app;
|
2021-04-30 15:31:54 +02:00
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
beforeAll(async () => {
|
2021-07-07 10:46:50 +02:00
|
|
|
db = await dbInit('routes_test_serial');
|
2021-05-28 11:10:24 +02:00
|
|
|
app = await setupAppWithBaseUrl(db.stores);
|
2021-04-30 15:31:54 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
afterAll(async () => {
|
|
|
|
await app.destroy();
|
|
|
|
if (db != null) {
|
|
|
|
await db.destroy();
|
|
|
|
}
|
2021-04-30 15:31:54 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('hitting a baseUri path returns HTML document', async () => {
|
|
|
|
expect.assertions(0);
|
|
|
|
await app.request
|
2021-04-30 15:31:54 +02:00
|
|
|
.get('/hosted')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', 'text/html; charset=utf-8');
|
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('hitting an api path that does not exist returns 404', async () => {
|
|
|
|
expect.assertions(0);
|
|
|
|
await app.request.get('/api/i-dont-exist').expect(404);
|
2021-05-05 09:01:39 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('hitting an /admin/api returns HTML document', async () => {
|
|
|
|
expect.assertions(0);
|
|
|
|
await app.request
|
2021-05-05 09:01:39 +02:00
|
|
|
.get('/admin/api')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', 'text/html; charset=utf-8');
|
2021-04-30 15:31:54 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('hitting a non-api returns HTML document', async () => {
|
|
|
|
expect.assertions(0);
|
|
|
|
await app.request
|
2021-04-30 15:31:54 +02:00
|
|
|
.get('/hosted/i-dont-exist')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', 'text/html; charset=utf-8');
|
|
|
|
});
|