1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const
|
13 | net = require('net'),
|
14 | windowslib = require('..');
|
15 |
|
16 | describe('log relay', function () {
|
17 | it('namespace should be an object', function () {
|
18 | should(windowslib.LogRelay).be.an.Function;
|
19 | });
|
20 |
|
21 | it('start log relay, receive TCP connection, get log message, shutdown', function (done) {
|
22 | this.timeout(5000);
|
23 | this.slow(4000);
|
24 |
|
25 | var relay = new windowslib.LogRelay();
|
26 | var testMsg = 'Hello World!';
|
27 |
|
28 | relay.on('started', function () {
|
29 | var client = net.createConnection(relay.tcpPort, function (conn) {
|
30 | client.write(relay.serverToken + '\n');
|
31 | client.write(testMsg);
|
32 | client.destroy();
|
33 | });
|
34 | });
|
35 |
|
36 | relay.on('message', function (msg) {
|
37 | relay.stop();
|
38 | should(msg).equal(testMsg);
|
39 | done();
|
40 | });
|
41 |
|
42 | relay.start();
|
43 | });
|
44 |
|
45 | it('start log relay, receive TCP connection, get log message, wait for buffers to flush, shutdown', function (done) {
|
46 | this.timeout(5000);
|
47 | this.slow(4000);
|
48 |
|
49 | var relay = new windowslib.LogRelay();
|
50 | var testMsg = 'Hello World!';
|
51 |
|
52 | relay.on('started', function () {
|
53 | var client = net.createConnection(relay.tcpPort, function (conn) {
|
54 | client.write(relay.serverToken + '\n');
|
55 | client.write(testMsg);
|
56 | });
|
57 | });
|
58 |
|
59 | relay.on('message', function (msg) {
|
60 | relay.stop();
|
61 | should(msg).equal(testMsg);
|
62 | done();
|
63 | });
|
64 |
|
65 | relay.start();
|
66 | });
|
67 | }); |
\ | No newline at end of file |