mawk
Table of Contents
# mawk.args(fn) - returns argument names for a function.
# mawk.as(name, value) - create a mock from a value.
# mawk.factory(name, fn) - create a mock from a factory function.
# mawk.require(name) - create a mock from a module.
# mawk.resolve(name) - returns the value of a mock.
# mawk.sanitize(name) - returns a safe mock name.
mawk.args(fn)
Returns the argument names for the function fn
as an array of strings.
var mock = ;{return one + two;}mock;// => [ 'one', 'two' ]
mawk.as(name, value)
Creates a mock with specified name
that resolves to the specified value
.
var mock = ;// pass name and value togethermock;// or pass name then value;mock;// => 1
mawk.factory(name, fn)
Creates a mock with specified name
that resolves to the value returned from
the function fn
.
var mock = ;;;{return one + two;}// pass name and function togethermock;// or pass name then function;mock;// => 3
mawk.require(name)
Creates a mock from the module with specified name
.
var mock = ;// in productionmock;mock;// => require('redis')// in development;mock;// => require('fakeredis')
mawk.resolve(name)
Returns the value of the mock with the specified name
.
var mock = ;;;mock;// => 1mock;// => 2
mawk.sanitize(name)
Returns a sanitized version of name
suitable for use as a JavaScript function argument.
var mock = ;mock;// => 'express'mock;// => 'safe'mock;// => 'bodyParser'mock;// => 'mawkjs'mock;// => 'file'