more component lifecycle tests
This commit is contained in:
parent
d8a402f4f5
commit
41cfda2719
2 changed files with 37 additions and 1 deletions
|
|
@ -26,7 +26,7 @@ Mithril's `config` method is now replaced by several lifecycle methods to improv
|
|||
|
||||
## Robustness
|
||||
|
||||
There are over 2100 assertions in the test suite, and tests cover even difficult-to-test things like `location.href`, `element.innerHTML` and `XMLHttpRequest` usage.
|
||||
There are over 2200 assertions in the test suite, and tests cover even difficult-to-test things like `location.href`, `element.innerHTML` and `XMLHttpRequest` usage.
|
||||
|
||||
## Modularity
|
||||
|
||||
|
|
|
|||
|
|
@ -272,6 +272,24 @@ o.spec("component", function() {
|
|||
}
|
||||
})
|
||||
})
|
||||
o("does not calls oninit on redraw", function() {
|
||||
var init = o.spy()
|
||||
var component = {
|
||||
view: function() {
|
||||
return {tag: "div", attrs: {id: "a"}, text: "b"}
|
||||
},
|
||||
oninit: init,
|
||||
}
|
||||
|
||||
function view() {
|
||||
return {tag: component}
|
||||
}
|
||||
|
||||
render(root, view())
|
||||
render(root, view())
|
||||
|
||||
o(init.callCount).equals(1)
|
||||
})
|
||||
o("calls oncreate", function() {
|
||||
var called = 0
|
||||
var component = {
|
||||
|
|
@ -295,6 +313,24 @@ o.spec("component", function() {
|
|||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
o(root.firstChild.firstChild.nodeValue).equals("b")
|
||||
})
|
||||
o("does not calls oncreate on redraw", function() {
|
||||
var create = o.spy()
|
||||
var component = {
|
||||
view: function() {
|
||||
return {tag: "div", attrs: {id: "a"}, text: "b"}
|
||||
},
|
||||
oncreate: create,
|
||||
}
|
||||
|
||||
function view() {
|
||||
return {tag: component}
|
||||
}
|
||||
|
||||
render(root, view())
|
||||
render(root, view())
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
})
|
||||
o("calls oncreate when returning fragment", function() {
|
||||
var called = 0
|
||||
var component = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue