-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathindex.spdy.test.js
55 lines (46 loc) · 1.33 KB
/
index.spdy.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const test = require('ava')
, servers = []
, events = require('harken')
, spdy = require('spdy')
, fs = require('fs')
, path = require('path')
, configStore = require('./utils/config');
test.beforeEach(() => {
configStore.reset();
});
test.afterEach(() => {
const shutDownEvents = events.required([ 'complete' ], () => {
// t.end();
});
servers.forEach((server, i) => {
shutDownEvents.add(`server:${i}`);
server.close(() => {
events.emit(`server:${i}`);
});
});
events.emit('complete');
});
test.cb('should return an spdy server when spdy and correct params are passed in', (t) => {
const spdyApp = require('./index');
spdyApp.server({
routeJSONPath: './test_stubs/routes_stub.json'
, routePath: './test_stubs'
, compress: false
, server: spdy
, port: 9995
, serverOptions: {
cert: fs.readFileSync(path.join(__dirname, './test_stubs/certs/test.crt'))
, key: fs.readFileSync(path.join(__dirname, './test_stubs/certs/tests.key'))
, ca: fs.readFileSync(path.join(__dirname, './test_stubs/certs/rootCA.key'))
}
, log: {
log: () => {}
}
});
spdyApp.events.once('server:started', (settings) => {
servers.push(settings.server);
t.true(settings.server instanceof spdy.Server);
t.end();
});
});