tests: Update tests for false -> "" behavior
This commit is contained in:
parent
6170573c29
commit
9f32267259
4 changed files with 20 additions and 8 deletions
|
|
@ -104,7 +104,7 @@ o.spec("component", function() {
|
|||
visible = false
|
||||
render(root, [{tag: component}])
|
||||
|
||||
o(root.firstChild.nodeValue).equals("false")
|
||||
o(root.firstChild.nodeValue).equals("")
|
||||
})
|
||||
o("updates root from null to null", function() {
|
||||
var component = {
|
||||
|
|
@ -232,7 +232,7 @@ o.spec("component", function() {
|
|||
render(root, [{tag: component}])
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("false")
|
||||
o(root.firstChild.nodeValue).equals("")
|
||||
})
|
||||
o("can return null", function() {
|
||||
var component = {
|
||||
|
|
@ -668,7 +668,7 @@ o.spec("component", function() {
|
|||
function init(vnode) {
|
||||
o(vnode.state.data).deepEquals(data)
|
||||
o(vnode.state.data).equals(data)
|
||||
|
||||
|
||||
//inherits state via prototype
|
||||
component.x = 1
|
||||
o(vnode.state.x).equals(1)
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ o.spec("hyperscript", function() {
|
|||
o("handles falsy boolean single child", function() {
|
||||
var vnode = m("div", {}, [false])
|
||||
|
||||
o(vnode.text).equals(false)
|
||||
o(vnode.text).equals("")
|
||||
})
|
||||
o("handles null single child", function() {
|
||||
var vnode = m("div", {}, [null])
|
||||
|
|
@ -261,7 +261,7 @@ o.spec("hyperscript", function() {
|
|||
var vnode = m("div", {}, [false, true])
|
||||
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals(false)
|
||||
o(vnode.children[0].children).equals("")
|
||||
o(vnode.children[1].tag).equals("#")
|
||||
o(vnode.children[1].children).equals(true)
|
||||
})
|
||||
|
|
@ -353,10 +353,16 @@ o.spec("hyperscript", function() {
|
|||
o(vnode.text).equals(true)
|
||||
})
|
||||
o("handles attr and single falsy boolean text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [0])
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(0)
|
||||
})
|
||||
o("handles attr and single false boolean text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [false])
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(false)
|
||||
o(vnode.text).equals("")
|
||||
})
|
||||
o("handles attr and single text child unwrapped", function() {
|
||||
var vnode = m("div", {a: "b"}, "c")
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ o.spec("normalize", function() {
|
|||
o(node.tag).equals("#")
|
||||
o(node.children).equals(true)
|
||||
})
|
||||
o("normalizes falsy boolean into text node", function() {
|
||||
o("normalizes falsy boolean into empty text node", function() {
|
||||
var node = Vnode.normalize(false)
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals(false)
|
||||
o(node.children).equals("")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -16,4 +16,10 @@ o.spec("normalizeChildren", function() {
|
|||
o(children[0].tag).equals("#")
|
||||
o(children[0].children).equals("a")
|
||||
})
|
||||
o("normalizes `false` values into empty string text nodes", function() {
|
||||
var children = Vnode.normalizeChildren([false])
|
||||
|
||||
o(children[0].tag).equals("#")
|
||||
o(children[0].children).equals("")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue