readline-testharness
Harness for testing modules that add functionality to the nodejs readline.
var wraprli= harness = createHarness = harnesscreate createRli = harnessrli; assert = ; var rli = hns = ; hns; assert;
Installation
npm i -D readline-testharness
API
harness.create(wrapperFn[, createRli]);
- creates a harness to test the given readline interface wrapper function
createRli
(rli mock creator function) is optional and default one is used if it is not given
harness functions/properties
hns.rli
the readline interface mockhns.rlw
the return value of the givenwrapperFn
hns.key(k)
simulates a key press.k
is a readline key (i.e.{ name: 's', ctrl: true }
)hns.keyed
keeps track of calls tohns.key
(mainly for test description)hns.code(c)
simulates a key press with the given code (c
)hns.coded
keeps track of calls tohns.code
(mainly for test description)hns.seq(s)
simulates a sequence of key presses, one for each char ins
hns.seqed
keeps track of calls tohns.seq
(mainly for test description)hns.reset
resets the state of the harness (i.e. creates newrli
andrlw
and resetskeyed
,coded
andseqed
hns.onreset
assign a function that you want to be called duringhns.reset
harness.rli()
- creates a readline interface mock that keeps track of functions called and properties on it
- it exposes properties of same name as the readline interface functions, i.e.,
moveCursor
tracks calls to_moveCursor
- this can be used to create the default one and customize it before passing it to the harness
- for more info consult its implementation