diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js
index 456a57fa..0d60cf7f 100644
--- a/tests/e2e/tests.js
+++ b/tests/e2e/tests.js
@@ -45,6 +45,7 @@ test('issue99 regression', function() {
m.render(dummyEl, view2);
equal(dummyEl.innerHTML, '
0
', 'view2 should be rendered correctly');
});
+
test('config handler context', function() {
expect(3);
var view = m('div', {config: function(evt, isInitialized, context){
@@ -58,4 +59,4 @@ test('config handler context', function() {
equal(context.data, 1);
}})
m.render(dummyEl, view);
-})
\ No newline at end of file
+})
diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js
index e0272473..9aa82bed 100644
--- a/tests/mithril-tests.js
+++ b/tests/mithril-tests.js
@@ -1023,9 +1023,39 @@ function testMithril(mock) {
test(function() {
return m.deps.factory.toString().indexOf("console") < 0
})
+
+ // config context
+ test(function() {
+ var root = mock.document.createElement("div")
+
+ var success = false;
+ m.render(root, m("div", {config: function(elem, isInitialized, ctx) {ctx.data=1}}));
+ m.render(root, m("div", {config: function(elem, isInitialized, ctx) {success = ctx.data===1}}));
+ 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: checkConfig});
+ m.render(root, [node, node]);
+ return success;
+ })
+
}
//mocks
testMithril(mock.window)
-test.print(console.log)
\ No newline at end of file
+test.print(console.log)