Skip to content

Commit

Permalink
fixup! lib: emit events about connection messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lundibundi committed Jul 19, 2017
1 parent 60a1c41 commit 2438231
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/node/connection-emit-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ test.afterEach((done) => {

test.test('must emit server and client events upon anonymous handshake',
(test) => {
test.plan(8);

const client = {
application: new jstp.Application('jstp', {}),
};
Expand Down Expand Up @@ -80,14 +82,15 @@ test.test('must emit server and client events upon anonymous handshake',
test.equal(connection.sessionId, app.sessionId,
'session id must be equal to the one provided by authCallback');
connection.close();
test.end();
});
});
}
);

test.test('must emit server and client events upon login/password handshake',
(test) => {
test.plan(8);

const client = {
application: new jstp.Application('jstp', {}),
};
Expand Down Expand Up @@ -129,37 +132,38 @@ test.test('must emit server and client events upon login/password handshake',
test.equal(connection.sessionId, app.sessionId,
'session id must be equal to the one provided by authCallback');
connection.close();
test.end();
});
});
}
);

test.test('must emit event on call with no arguments and no return value',
(test) => {
test.plan(5);

const iface = 'calculator';
const methodName = 'doNothing';
const args = [];
addCallEventCheck(test, server.getClients()[0], iface, methodName, args);
connection.on('callback', (error, ok) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(ok, [], 'Ok contents must match');
test.end();
});
connection.callMethod(iface, methodName, args);
}
);

test.test('must emit event on call with no arguments and return value',
(test) => {
test.plan(5);

const iface = 'calculator';
const methodName = 'answer';
const args = [];
addCallEventCheck(test, server.getClients()[0], iface, methodName, args);
connection.on('callback', (error, ok) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(ok, [42], 'Ok contents must match');
test.end();
});
connection.callMethod(iface, methodName, args);
}
Expand Down

0 comments on commit 2438231

Please sign in to comment.