-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathindex.test.js
More file actions
42 lines (34 loc) · 1.16 KB
/
index.test.js
File metadata and controls
42 lines (34 loc) · 1.16 KB
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
import fastify from 'fastify';
import _ from 'lodash';
import init from '../server/plugin.js';
describe('app', () => {
let app;
beforeAll(async () => {
app = fastify();
await init(app);
});
it('main page without environment variable SERVER_MESSAGE', async () => {
_.unset(process.env, 'SERVER_MESSAGE');
const res = await app.inject({
method: 'GET',
url: '/',
});
expect(res.statusCode).toBe(200);
expect(res.body).toMatch('Привет от Хекслета!');
expect(res.body).toMatch('Приложение запущено, но сообщение сервера не установлено!');
});
it('main page with environment variable SERVER_MESSAGE', async () => {
process.env.SERVER_MESSAGE = 'Hexlet Awesome Server';
const res = await app.inject({
method: 'GET',
url: '/',
});
expect(res.statusCode).toBe(200);
expect(res.body).toMatch('Привет от Хекслета!');
expect(res.body).toMatch(`Приложение запущено и передает сообщение: ${process.env.SERVER_MESSAGE}`);
});
//
// after all(() => {
// app.close();
// });
});