Socket
Book a DemoInstallSign in
Socket

42-cent-mock

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

42-cent-mock

fake implementation of 42-cent gateway for tests

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

42-cent-mock

mock implementation of abstract 42-cent payement gateway to use for tests

usage

  • register the mock factory in place of whatever gateway, the factory will return a singleton instance of the mocked gateway
var cent42=require('42-cent');
var gm=require('42-cent-mock');

cent42.registerGateway('Authorize.net',gm.factory);

  • stub call and make assertions on arguments
var stub = gm.when('refundTransaction').resolveWith({status:'success'});

gm.factory().refundTransaction('666',{amount:123});

assert.equal(stub.calls.length,1);
assert.equal(stub.calls[0][0], '666')
assert.equal(stub.calls[0][1].amount,123);
  • clean the currently set stubs (tear down phase of your test)
gm.clean();

Keywords

test

FAQs

Package last updated on 22 May 2015

Did you know?

Socket

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