-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.spec.ts
More file actions
75 lines (60 loc) · 2.32 KB
/
index.spec.ts
File metadata and controls
75 lines (60 loc) · 2.32 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { ServerInjectOptions } from '@hapi/hapi';
import { getConfig } from '../../../src/config';
import { initServer } from '../../../src/server';
describe('/health', () => {
describe('GET /health', () => {
it('returns 200 OK if everything is well configured', async () => {
const subject = await initServer(getConfig());
const request: ServerInjectOptions = { method: 'GET', url: '/health' };
const { statusCode } = await subject.inject(request);
expect(statusCode).toEqual(200);
});
describe('Twitch Config', () => {
it('returns that the Twitch Bot is configured', async () => {
const subject = await initServer({
...getConfig(),
TWITCH_BOT_CHANNEL: 'streamdevs',
TWITCH_BOT_NAME: 'streamdevs',
TWITCH_BOT_TOKEN: 'token',
});
const request: ServerInjectOptions = { method: 'GET', url: '/health' };
const { result } = await subject.inject(request);
expect(result).toEqual(
expect.objectContaining({ config: expect.objectContaining({ twitch: true }) }),
);
});
it("returns that the Twitch Bot isn't configured", async () => {
const subject = await initServer({ ...getConfig(), TWITCH_BOT_CHANNEL: undefined });
const request: ServerInjectOptions = { method: 'GET', url: '/health' };
const { result } = await subject.inject(request);
expect(result).toEqual(
expect.objectContaining({ config: expect.objectContaining({ twitch: false }) }),
);
});
});
describe('StreamLabs Config', () => {
it('returns that StreamLabs is configured', async () => {
const subject = await initServer({
...getConfig(),
STREAMLABS_TOKEN: 'token',
});
const request: ServerInjectOptions = { method: 'GET', url: '/health' };
const { result } = await subject.inject(request);
expect(result).toEqual(
expect.objectContaining({ config: expect.objectContaining({ streamLabs: true }) }),
);
});
it('returns that StreamLabs is configured', async () => {
const subject = await initServer({
...getConfig(),
STREAMLABS_TOKEN: undefined,
});
const request: ServerInjectOptions = { method: 'GET', url: '/health' };
const { result } = await subject.inject(request);
expect(result).toEqual(
expect.objectContaining({ config: expect.objectContaining({ streamLabs: false }) }),
);
});
});
});
});