Socket
Socket
Sign inDemoInstall

lapin-mock

Package Overview
Dependencies
1
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lapin-mock

Mock for lapin


Version published
Weekly downloads
1
Maintainers
3
Install size
441 kB
Created
Weekly downloads
 

Readme

Source

Lapin Mock

Mock for lapin.

Usage

Requirements.

  • sinon for stubbing
'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' );
  } );
  
} );

FAQs

Last updated on 08 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc