initial commit (work in progress)
This commit is contained in:
parent
13fdb60f66
commit
559369016d
83 changed files with 10461 additions and 0 deletions
62
render/tests/test-createNodes.js
Normal file
62
render/tests/test-createNodes.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var domMock = require("../../test-utils/domMock")
|
||||
var vdom = require("../../render/render")
|
||||
|
||||
o.spec("createNodes", function() {
|
||||
var $window, root, render
|
||||
o.beforeEach(function() {
|
||||
$window = domMock()
|
||||
root = $window.document.createElement("div")
|
||||
render = vdom($window).render
|
||||
})
|
||||
|
||||
o("creates nodes", function() {
|
||||
var vnodes = [
|
||||
{tag: "a"},
|
||||
{tag: "#", children: "b"},
|
||||
{tag: "<", children: "c"},
|
||||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
o(root.childNodes[2].nodeValue).equals("c")
|
||||
o(root.childNodes[3].nodeValue).equals("d")
|
||||
})
|
||||
o("ignores null", function() {
|
||||
var vnodes = [
|
||||
{tag: "a"},
|
||||
{tag: "#", children: "b"},
|
||||
null,
|
||||
{tag: "<", children: "c"},
|
||||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
o(root.childNodes[2].nodeValue).equals("c")
|
||||
o(root.childNodes[3].nodeValue).equals("d")
|
||||
})
|
||||
o("ignores undefined", function() {
|
||||
var vnodes = [
|
||||
{tag: "a"},
|
||||
{tag: "#", children: "b"},
|
||||
undefined,
|
||||
{tag: "<", children: "c"},
|
||||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
o(root.childNodes[2].nodeValue).equals("c")
|
||||
o(root.childNodes[3].nodeValue).equals("d")
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue