2021-04-04 21:13:16 +02:00
|
|
|
import request from 'supertest';
|
2021-10-29 17:33:05 +02:00
|
|
|
|
2021-04-04 21:13:16 +02:00
|
|
|
import { runServer } from '../src';
|
2021-10-29 17:33:05 +02:00
|
|
|
|
2021-04-04 21:13:16 +02:00
|
|
|
describe('startServer via API', () => {
|
|
|
|
test('should provide all HTTP server data', async () => {
|
|
|
|
const webServer = await runServer();
|
|
|
|
expect(webServer).toBeDefined();
|
|
|
|
await request(webServer).get('/').expect(200);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should fail on start with empty configuration', async () => {
|
|
|
|
// @ts-expect-error
|
|
|
|
await expect(runServer({})).rejects.toThrow(
|
|
|
|
'AssertionError [ERR_ASSERTION]: CONFIG: storage path not defined'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should fail on start with null as entry', async () => {
|
|
|
|
await expect(runServer(null)).rejects.toThrow('config file must be an object');
|
|
|
|
});
|
|
|
|
});
|