Tests use hyperscript instead of manually constructing nodes
This commit is contained in:
parent
5502570b16
commit
31d2ed4be8
27 changed files with 1515 additions and 1841 deletions
|
|
@ -13,59 +13,57 @@ o.spec("createText", function() {
|
|||
})
|
||||
|
||||
o("creates string", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
render(root, [vnode])
|
||||
var vnode = "a"
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("a")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
o("creates falsy string", function() {
|
||||
var vnode = {tag: "#", children: ""}
|
||||
render(root, [vnode])
|
||||
var vnode = ""
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals("")
|
||||
})
|
||||
o("creates number", function() {
|
||||
var vnode = {tag: "#", children: 1}
|
||||
render(root, [vnode])
|
||||
var vnode = 1
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("1")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals("1")
|
||||
})
|
||||
o("creates falsy number", function() {
|
||||
var vnode = {tag: "#", children: 0}
|
||||
render(root, [vnode])
|
||||
var vnode = 0
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("0")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals("0")
|
||||
})
|
||||
o("creates boolean", function() {
|
||||
var vnode = {tag: "#", children: true}
|
||||
render(root, [vnode])
|
||||
o("ignores true boolean", function() {
|
||||
var vnode = true
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("true")
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("creates falsy boolean", function() {
|
||||
var vnode = {tag: "#", children: false}
|
||||
render(root, [vnode])
|
||||
o("creates false boolean", function() {
|
||||
var vnode = false
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("false")
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("creates spaces", function() {
|
||||
var vnode = {tag: "#", children: " "}
|
||||
render(root, [vnode])
|
||||
var vnode = " "
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals(" ")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals(" ")
|
||||
})
|
||||
o("ignores html", function() {
|
||||
var vnode = {tag: "#", children: "<a></a>™"}
|
||||
render(root, [vnode])
|
||||
var vnode = "<a></a>™"
|
||||
render(root, vnode)
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("<a></a>™")
|
||||
o(root.firstChild.nodeName).equals("#text")
|
||||
o(root.firstChild.nodeValue).equals("<a></a>™")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue