1.3 KiB
1.3 KiB
m.deps
This is a testing method to set the window object in an environment that does not have it (such as the server).
It will normally not be used in an application, as window is already available to Mithril.
For normal (client-side) use of mithril, this method will not be used.
It is used in Mithril's testing suite, and can be used to supply a mock window for browserless testing.
Usage
Call it at the beginning of your test file to supply a mock window:
function testMithril(mockWindow) {
window = m.deps(mockWindow);
// Your tests here...
}
Signature
Window m.deps(Object window)
where:
Window :: Object<any>
-
Object Window
This should be a mock of the
windowobject.Mithril uses certain
windowmethods that will need to be made available for complete test coverage, depending on your application:window.document- Mithril also uses certain methods on the DOM node object
window.requestAnimationFrame/window.cancelAnimationFrame- Falls back to
window.setTimeout/window.clearTimeout window.locationwindow.historywindow.scrollTowindow.XMLHttpRequest
-
returns Window
The returned window is the same as that passed in.