Skip to content

ssb-junkyard/muxrpc-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuxRPC Mock

Generate mock APIs from muxrpc manifests. Useful for generating test suites.

var muxmock = require('muxrpc-mock')

// typical muxrpc manifest:
var manifest = {
  async: 'async',
  source: 'source',
  sink: 'sink',
  duplex: 'duplex'
}

var api = muxmock(manifest)
// api now has all methods defined, but each do nothing

You can specify functions to be called when the api methods are hit:

var api = muxmock(manifest, {
  onAsync: function (method, arguments) {
    // async method called
    // `method` is the name of the function called
    // `arguments` is the parameters of the call
  },
  onSource: function (method, arguments) {
    // source or duplex method called
    // `method` is the name of the function called
    // `arguments` is the parameters of the call
  },
  onSink: function (method, data) {
    // sink or duplex method called
    // `method` is the name of the function called
    // `data` is the collected data from the pull stream
  }
})

About

Generate mock APIs from muxrpc manifests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published