UNPKG

mqrpc

Version:

💫 Easy RPC over RabbitMQ

23 lines (22 loc) • 900 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ava_1 = require("ava"); const sinon = require("sinon"); const _config_1 = require("../_config"); const RpcServer_1 = require("../../lib/RpcServer"); ava_1.default.beforeEach(async (t) => { t.context.sandbox = sinon.sandbox.create(); t.context.server = new RpcServer_1.default({ amqpClient: { amqpUrl: _config_1.AMQP_URL } }); await t.context.server.init(); }); ava_1.default.afterEach(t => t.context.sandbox.restore()); ava_1.default('[unit] #term calls #term on the Amqp client', async (t) => { const spy = t.context.sandbox.spy(t.context.server.amqpClient, 'term'); await t.context.server.term(); sinon.assert.calledOnce(spy); t.pass(); }); ava_1.default('[unit] #term is idempotent', async (t) => { await t.context.server.term(); await t.notThrows(t.context.server.term()); });