1.1.0 • Published 9 years ago

lapin-mock v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Lapin Mock

Mock for lapin.

Usage

Requirements.

'use strict';

var lapinMock = require( 'lapin-mock' );
var sinon     = require( 'sinon' );

describe( 'test', function() {
  
  var sendMock;
  var rabbitAPI;
  var mockRabbit;
  
  before( function ( done ) {
  
    rabbitAPI = lapinMock.rabbitAPI;
    mockRabbit = sinon.stub( rabbitAPI );
    sendMock = new lapinMock.SendMock( done );
    
    rabbitAPI.respond.onCall( 0 ).callsArgWith( 1, message, sendMock );
    
    require( 'to-test-file.js' )( mockRabbit );
    
  } );
  
  it( 'Here we get data form sendMock for sucesss', function () {
    // This is for success
    sendMock.response.should.equal( 'to test value' );
  } );
  
  it( 'Here we get data form sendMock for error', function () {
    // This is for success
    sendMock.errorMessage.should.equal( 'to test value' );
    sendMock.error.should.equal( errorObj );
    sendMock.code.should.equal( 400 );
    
  } );
  
  it( 'Here we get data form sendMock for sucess', function () {
    // This is for success
    sendMock.errorMessage.should.equal( 'to test value' );
  } );
  
} );
1.1.0

9 years ago

1.0.0

9 years ago