-
Notifications
You must be signed in to change notification settings - Fork 33
/
server-events-all.spec.js
49 lines (41 loc) · 1.76 KB
/
server-events-all.spec.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
const test = require('tape');
const helper = require('node-red/test/nodes/helper');
const ConfigServerNode = require('../../nodes/config-server/config-server');
const ServerEventsNode = require('../../nodes/server-events-all/server-events-all');
test('before: start-server', function(t) {
helper.startServer(() => t.end());
});
test('Simple Node: should load', function(t) {
let flow = [
{ id: 'n1', type: 'server-events', server: 'n2', wires: [] },
{ id: 'n2', type: 'server', name: 'ha-server', url: 'http://localhost:1234', pass: '123' }
];
helper.load([ServerEventsNode, ConfigServerNode], flow, function() {
const n1 = helper.getNode('n1');
t.equals(n1.type, 'server-events', 'simple node should instantiate with type "simple-node"');
helper.unload();
t.end();
});
});
// test('Simple Node: should send lowercased payload', function(t) {
// let flow = [
// { id: 'n1', type: 'simple-node', server: 'n2', wires: [ ['n3'] ] },
// { id: 'n2', type: 'config-node', host: 'localhost', port: '1234' },
// { id: 'n3', type: 'helper' }
// ];
// helper.load([ConfigNode, SimpleNode], flow, function() {
// const n1 = helper.getNode('n1');
// const n3 = helper.getNode('n3');
// n3.on('input', function(msg) {
// t.equals(msg.topic, expectedMsg.topic, 'topics should match');
// t.equals(msg.payload, expectedMsg.payload.toLowerCase(), 'payload should be lowercased match');
// t.end();
// });
// const expectedMsg = { topic: 'test', payload: 'ABC' };
// n1.receive(expectedMsg);
// });
// });
test('after: stop-server', function(t) {
helper.stopServer();
t.end();
});