forked from hpi-sam/digital-fuesim-manv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secure-on.spec.ts
23 lines (22 loc) · 1 KB
/
secure-on.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { sleep } from 'digital-fuesim-manv-shared';
import { createTestEnvironment } from '../../../test/utils';
describe('secure on', () => {
const environment = createTestEnvironment();
it('does not crash in production environment when fed with invalid data', async () => {
const originalEnv = process.env['NODE_ENV'];
// Errors are only catched in production mode
process.env['NODE_ENV'] = 'production';
await environment
.withWebsocket(async (socket) => {
socket.insecureEmit('getState', 'any');
// wait a bit so that the error can occur
await sleep(1000);
// Check whether the server is still available
await environment.httpRequest('get', '/api/health').expect(200);
})
.finally(() => {
process.env['NODE_ENV'] = originalEnv;
});
});
// TODO: test that it does crash in development environment when fed with invalid data
});