Merge remote-tracking branch 'origin/next' into next
Conflicts: mithril.js tests/e2e/tests.js
This commit is contained in:
commit
4020933780
2 changed files with 33 additions and 2 deletions
|
|
@ -45,6 +45,7 @@ test('issue99 regression', function() {
|
|||
m.render(dummyEl, view2);
|
||||
equal(dummyEl.innerHTML, '<div><span>0</span></div>', 'view2 should be rendered correctly');
|
||||
});
|
||||
|
||||
test('config handler context', function() {
|
||||
expect(3);
|
||||
var view = m('div', {config: function(evt, isInitialized, context){
|
||||
|
|
|
|||
|
|
@ -1023,6 +1023,36 @@ 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue