Added more tests for config context
This commit is contained in:
parent
5a2d7fdf81
commit
164e5b178c
1 changed files with 20 additions and 0 deletions
|
|
@ -936,6 +936,26 @@ function testMithril(mock) {
|
||||||
m.render(root, m("div", {config: function(elem, isInitialized, ctx) {success = ctx.data===1}}));
|
m.render(root, m("div", {config: function(elem, isInitialized, ctx) {success = ctx.data===1}}));
|
||||||
return success;
|
return success;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// more complex config context
|
||||||
|
test(function() {
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
|
||||||
|
var idx = 0;
|
||||||
|
var success = true;
|
||||||
|
var statefulConfig = function(elem, isInitialized, ctx) {ctx.data=idx++}
|
||||||
|
var node = m("div", {config: statefulConfig});
|
||||||
|
m.render(root, [node, node]);
|
||||||
|
|
||||||
|
idx = 0;
|
||||||
|
var checkConfig = function(elem, isInitialized, ctx) {
|
||||||
|
success = success && (ctx.data === idx++)
|
||||||
|
}
|
||||||
|
node = m("div", {config: statefulConfig});
|
||||||
|
m.render(root, [node, node]);
|
||||||
|
return success;
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//mocks
|
//mocks
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue