more tests
This commit is contained in:
parent
a2c01d1d96
commit
e7420e72e1
14 changed files with 596 additions and 215 deletions
|
|
@ -150,6 +150,26 @@ o.spec("component", function() {
|
|||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("false")
|
||||
})
|
||||
o("can return null", function() {
|
||||
var component = {
|
||||
view: function(vnode) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can return undefined", function() {
|
||||
var component = {
|
||||
view: function(vnode) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can update when returning fragments", function() {
|
||||
var component = {
|
||||
view: function(vnode) {
|
||||
|
|
@ -178,6 +198,17 @@ o.spec("component", function() {
|
|||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
o("can update when returning null", function() {
|
||||
var component = {
|
||||
view: function(vnode) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
render(root, [{tag: component}])
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can remove when returning fragments", function() {
|
||||
var component = {
|
||||
view: function(vnode) {
|
||||
|
|
@ -507,4 +538,22 @@ o.spec("component", function() {
|
|||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
})
|
||||
o.spec("state", function() {
|
||||
o("deep copies state", function() {
|
||||
var called = 0
|
||||
var component = {
|
||||
data: [{a: 1}],
|
||||
oninit: init,
|
||||
view: function() {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
function init(vnode) {
|
||||
o(vnode.state.data).deepEquals([{a: 1}])
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue