-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.spec.js
More file actions
78 lines (60 loc) · 2.22 KB
/
index.spec.js
File metadata and controls
78 lines (60 loc) · 2.22 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
76
77
78
"use strict";
// ===================================================================
const assert = require("assert/strict");
const tcpBind = require("tcp-bind");
const { describe, it } = require("tap").mocha;
const HttpServerPlus = require("./");
// ===================================================================
describe("HttpServerPlus", function () {
describe("#create()", function () {
it("creates a new instance", function () {
assert(HttpServerPlus.create() instanceof HttpServerPlus);
});
it("can register a `request` listener", function () {
const listener = function () {};
const server = HttpServerPlus.create(listener);
assert.deepEqual(server.listeners("request"), [listener]);
});
});
describe(".addresses()", function () {
it.todo("returns the list of addresses the server is listening at");
});
describe(".niceAddresses()", function () {
it.todo(
"returns the list of human readable addresses the server is listening at"
);
});
// TODO
describe(".listen()", function () {
it.todo("can use a host:port");
// FIXME: `tcp-bind` does not work anymore
it.skip("can use a systemd socket", function () {
const SD_LISTEN_FDS_START = 3;
const server = HttpServerPlus.create();
const fd = tcpBind(0);
const env = process.env;
env.LISTEN_FDS = fd - SD_LISTEN_FDS_START + 1;
env.LISTEN_PID = process.pid;
return server
.listen({
systemdSocket: fd - SD_LISTEN_FDS_START, // systemd fds start at 3 but we have not control over it in Node.
})
.then(function () {
delete env.LISTEN_FDS;
delete env.LISTEN_PID;
return server.close();
});
});
it.todo("can use a socket");
it.todo("can use a HTTPS certificate");
it.todo("returns a promise which will resolve once listening");
it.todo("returns a promise which will reject if failure");
});
describe(".close()", function () {
it.todo("closes all servers");
it.todo("emit the `close` event when all servers are closed");
it.todo("emit the `close` event even if there are no servers");
});
// TODO
it.todo("can be used exactly like `{http,https}.Server`");
});