Karen
Karen is a collection of mock objects, for example window, document and node.
Installation
$ npm install karen --save-dev
API
These are the main mock objects:
MockWindow
MockDocument
MockElement
MockNode
MockLocation
MockNavigator
MockScreen
MockDate
See code/tests for resp class on how to use.
Usage
As a simple example, let's say we want to add some syntactic sugar
around setTimeout
, with the following API:
timer = Timerwindowtimerdelay 100-> # do something on 'event'-> timerstop
Here is the implementation of Timer
:
= : timeout = windowsetTimeoutcallbackms : -> windowclearTimeouttimeout
And a simple test using Mocha.js:
describe 'Timer'-> it 'runs callback' mockWindow = timer = TimermockWindow timerdelay100done mockWindowtick100
Copyright
© 2014-2015 Burt AB, see LICENSE.txt (BSD 3-Clause).