@workablehr/riviere
Version:
log inbound/outbound HTTP traffic
35 lines (27 loc) • 939 B
JavaScript
const sinon = require('sinon');
const should = require('should');
const Loggable = require('./../../../lib/loggable');
const sandbox = sinon.createSandbox();
const adapter = {
onInboundRequest: sandbox.spy(),
onOutboundResponse: sandbox.spy(),
onError: sandbox.spy()
};
const loggable = new Loggable({ adapter });
describe('#loggable', () => {
after(() => {
sandbox.restore();
});
it('should emit INBOUND_REQUEST event', () => {
loggable.emit(loggable.constructor.EVENT.INBOUND_REQUEST);
adapter.onInboundRequest.calledOnce.should.equal(true);
});
it('should emit INBOUND_REQUEST event', () => {
loggable.emit(loggable.constructor.EVENT.OUTBOUND_RESPONSE);
adapter.onOutboundResponse.calledOnce.should.equal(true);
});
it('should emit INBOUND_REQUEST event', () => {
loggable.emit(loggable.constructor.EVENT.UNEXPECTED_ERROR);
adapter.onError.calledOnce.should.equal(true);
});
});