forked from clarkie/hapi-cloudwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
33 lines (25 loc) · 896 Bytes
/
index.test.js
File metadata and controls
33 lines (25 loc) · 896 Bytes
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
import test from 'ava';
import Hapi from 'hapi';
import plugin from './index';
test('plugin registered', async t => {
const server = new Hapi.Server({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: request => 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({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: request => request.app });
const options = {
enabled: false,
environmentName: 'integration',
region: 'ap-west-1',
metricsSentCallback: () => {},
};
await server.register({ plugin, options });
const { result } = await server.inject({ url: '/' });
t.truthy(result.startTime);
t.truthy(result.endTime);
});