2021-04-04 14:13:16 -05:00
|
|
|
import request from 'supertest';
|
2021-10-29 10:33:05 -05:00
|
|
|
|
2021-04-04 14:13:16 -05:00
|
|
|
import { runServer } from '../src';
|
2021-10-29 10:33:05 -05:00
|
|
|
|
2021-04-04 14:13:16 -05: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
|
2023-02-26 16:24:00 -05:00
|
|
|
await expect(runServer({})).rejects.toThrow('configPath property is required');
|
2021-04-04 14:13:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('should fail on start with null as entry', async () => {
|
2022-10-10 01:00:09 -05:00
|
|
|
// @ts-expect-error
|
2022-07-29 13:51:45 -05:00
|
|
|
await expect(runServer(null)).rejects.toThrow();
|
2021-04-04 14:13:16 -05:00
|
|
|
});
|
|
|
|
});
|