Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
enigmatic00 committed Jun 20, 2016
1 parent eb30307 commit 84adbd7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/unit/fudd.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,18 @@ describe('fudd', function() {
});
});

describe('_disconnect & createChannel', function() {
describe('_connect, _disconnect & createChannel', function() {

var formatAmqpUtilsStub;
var connectStub;

before(function() {
mockery.resetCache();
mockery.deregisterAll();
mockery.registerAllowable('../../lib/fudd.js');
mockery.registerMock('amqplib/callback_api', {});
mockery.registerMock('amqplib/callback_api', {connect: connectStub = sinon.stub()});
mockery.registerMock('palinode', {});
mockery.registerMock('./amqp-config-utils.js', {});
mockery.registerMock('./amqp-config-utils.js', formatAmqpUtilsStub = sinon.stub());
Fudd = require('../../lib/fudd.js');
});

Expand All @@ -481,6 +484,19 @@ describe('fudd', function() {
});
});

describe('_connect', function() {
it('should call formatAmqpUtils with config.cluster', function() {
Fudd._connect(connection, callbackSpy);
expect(formatAmqpUtilsStub.calledWith(config.cluster)).to.eql(true);
});

it('should call connect with url & callback', function() {
formatAmqpUtilsStub.returns('a.url');
Fudd._connect(connection, callbackSpy);
expect(connectStub.calledWith('a.url', callbackSpy)).to.eql(true);
});
});

describe('_createChannel', function() {
it('should call back with the error from createChannel', function() {
var expectedError = new Error('connection is borked');
Expand Down

0 comments on commit 84adbd7

Please sign in to comment.