faux-moz-dom
v1.0.0
Published
Mock implementations of DOMRequest and DOMCursor for testing purposes.
Downloads
1
Maintainers
Readme
faux-moz-dom
At this point, I’m not even sold on this being a good idea…
Install
$ npm install michaelrhodes/faux-moz-dom
Usage
var FauxDOMRequest = require('faux-moz-dom/request')
var FauxDOMCursor = require('faux-moz-dom/cursor')
var requestSomething = function () {
var request = new FauxDOMRequest
setTimeout(function () {
request.readyState = 'done'
request.result = 'Great job!'
if (typeof request.onsuccess === 'function') {
request.onsuccess()
}
})
return request
}
var badCursor = function () {
var cursor = new FauxDOMCursor
setTimeout(function () {
cursor.readyState = 'done'
cursor.error = new DOMError('NO_GO')
if (typeof cursor.onerror === 'function') {
cursor.onerror()
}
})
return cursor
}