mqrpc
Version:
💫 Easy RPC over RabbitMQ
29 lines (28 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const comms_1 = require("../../../lib/RpcServer/comms");
ava_1.default('[unit] #extractCallContent throws when there is no replyTo in the properties', t => {
t.throws(() => comms_1.extractCallContent({ properties: {} }), Error, 'Message has no replyTo');
});
ava_1.default('[unit] #extractCallContent throws when there is no correlationId in the properties', t => {
t.throws(() => comms_1.extractCallContent({ properties: { replyTo: 12345 } }), Error, 'Message has no correlationId');
});
ava_1.default('[unit] #extractCallContent throws when the content isn\'t valid JSON', t => {
t.throws(() => comms_1.extractCallContent({
content: new Buffer('gibberish'),
properties: { replyTo: 12345, correlationId: 'a' }
}), Error, 'Message could not be parsed:');
});
ava_1.default('[unit] #extractCallContent returns the parsed call content', t => {
const payload = {
procedure: 'mqrpc.echo',
args: [42],
timeouts: { ackTimeout: 42 }
};
const result = comms_1.extractCallContent({
content: new Buffer(JSON.stringify(payload)),
properties: { replyTo: 12345, correlationId: 'a' }
});
t.deepEqual(result, payload);
});