-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.test.js
35 lines (27 loc) · 984 Bytes
/
index.test.js
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
import test from 'ava';
import Hapi from 'hapi';
import plugin from './index';
test('plugin registered', async t => {
const server = new Hapi.Server();
server.connection({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: (request, reply) => reply(request.app) });
await server.register(plugin);
const { result } = await server.inject({ url: '/' });
t.truthy(result.startTime);
t.truthy(result.endTime);
});
test('plugin registered with all options', async t => {
const server = new Hapi.Server();
server.connection({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: (request, reply) => reply(request.app) });
const options = {
enabled: false,
environmentName: 'integration',
region: 'ap-west-1',
metricsSentCallback: () => {},
};
await server.register({ register: plugin, options });
const { result } = await server.inject({ url: '/' });
t.truthy(result.startTime);
t.truthy(result.endTime);
});