Tests: wrap the rest of the components definitions

This commit is contained in:
Pierre-Yves Gerardy 2017-02-19 02:07:48 +01:00
parent ac38335453
commit 24243dba94
3 changed files with 104 additions and 104 deletions

View file

@ -20,11 +20,11 @@ o.spec("component", function() {
o.spec("basics", function() { o.spec("basics", function() {
o("works", function() { o("works", function() {
var component = { var component = createComponent({
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
var node = {tag: component} var node = {tag: component}
render(root, [node]) render(root, [node])
@ -34,11 +34,11 @@ o.spec("component", function() {
o(root.firstChild.firstChild.nodeValue).equals("b") o(root.firstChild.firstChild.nodeValue).equals("b")
}) })
o("receives arguments", function() { o("receives arguments", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs, text: vnode.text} return {tag: "div", attrs: vnode.attrs, text: vnode.text}
} }
} })
var node = {tag: component, attrs: {id: "a"}, text: "b"} var node = {tag: component, attrs: {id: "a"}, text: "b"}
render(root, [node]) render(root, [node])
@ -48,11 +48,11 @@ o.spec("component", function() {
o(root.firstChild.firstChild.nodeValue).equals("b") o(root.firstChild.firstChild.nodeValue).equals("b")
}) })
o("updates", function() { o("updates", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs, text: vnode.text} return {tag: "div", attrs: vnode.attrs, text: vnode.text}
} }
} })
render(root, [{tag: component, attrs: {id: "a"}, text: "b"}]) render(root, [{tag: component, attrs: {id: "a"}, text: "b"}])
render(root, [{tag: component, attrs: {id: "c"}, text: "d"}]) render(root, [{tag: component, attrs: {id: "c"}, text: "d"}])
@ -62,11 +62,11 @@ o.spec("component", function() {
}) })
o("updates root from null", function() { o("updates root from null", function() {
var visible = false var visible = false
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return visible ? {tag: "div"} : null return visible ? {tag: "div"} : null
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
visible = true visible = true
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -75,11 +75,11 @@ o.spec("component", function() {
}) })
o("updates root from primitive", function() { o("updates root from primitive", function() {
var visible = false var visible = false
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return visible ? {tag: "div"} : false return visible ? {tag: "div"} : false
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
visible = true visible = true
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -88,11 +88,11 @@ o.spec("component", function() {
}) })
o("updates root to null", function() { o("updates root to null", function() {
var visible = true var visible = true
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return visible ? {tag: "div"} : null return visible ? {tag: "div"} : null
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
visible = false visible = false
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -101,11 +101,11 @@ o.spec("component", function() {
}) })
o("updates root to primitive", function() { o("updates root to primitive", function() {
var visible = true var visible = true
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return visible ? {tag: "div"} : false return visible ? {tag: "div"} : false
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
visible = false visible = false
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -113,22 +113,22 @@ o.spec("component", function() {
o(root.firstChild.nodeValue).equals("") o(root.firstChild.nodeValue).equals("")
}) })
o("updates root from null to null", function() { o("updates root from null to null", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return null return null
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.childNodes.length).equals(0) o(root.childNodes.length).equals(0)
}) })
o("removes", function() { o("removes", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return {tag: "div"} return {tag: "div"}
} }
} })
var div = {tag: "div", key: 2} var div = {tag: "div", key: 2}
render(root, [{tag: component, key: 1}, div]) render(root, [{tag: component, key: 1}, div])
render(root, [{tag: "div", key: 2}]) render(root, [{tag: "div", key: 2}])
@ -137,21 +137,21 @@ o.spec("component", function() {
o(root.firstChild).equals(div.dom) o(root.firstChild).equals(div.dom)
}) })
o("svg works when creating across component boundary", function() { o("svg works when creating across component boundary", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return {tag: "g"} return {tag: "g"}
} }
} })
render(root, [{tag: "svg", children: [{tag: component}]}]) render(root, [{tag: "svg", children: [{tag: component}]}])
o(root.firstChild.firstChild.namespaceURI).equals("http://www.w3.org/2000/svg") o(root.firstChild.firstChild.namespaceURI).equals("http://www.w3.org/2000/svg")
}) })
o("svg works when updating across component boundary", function() { o("svg works when updating across component boundary", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return {tag: "g"} return {tag: "g"}
} }
} })
render(root, [{tag: "svg", children: [{tag: component}]}]) render(root, [{tag: "svg", children: [{tag: component}]}])
render(root, [{tag: "svg", children: [{tag: component}]}]) render(root, [{tag: "svg", children: [{tag: component}]}])
@ -160,14 +160,14 @@ o.spec("component", function() {
}) })
o.spec("return value", function() { o.spec("return value", function() {
o("can return fragments", function() { o("can return fragments", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return [ return [
{tag: "label"}, {tag: "label"},
{tag: "input"}, {tag: "input"},
] ]
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.childNodes.length).equals(2) o(root.childNodes.length).equals(2)
@ -175,98 +175,98 @@ o.spec("component", function() {
o(root.childNodes[1].nodeName).equals("INPUT") o(root.childNodes[1].nodeName).equals("INPUT")
}) })
o("can return string", function() { o("can return string", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return "a" return "a"
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("a") o(root.firstChild.nodeValue).equals("a")
}) })
o("can return falsy string", function() { o("can return falsy string", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return "" return ""
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("") o(root.firstChild.nodeValue).equals("")
}) })
o("can return number", function() { o("can return number", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return 1 return 1
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("1") o(root.firstChild.nodeValue).equals("1")
}) })
o("can return falsy number", function() { o("can return falsy number", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return 0 return 0
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("0") o(root.firstChild.nodeValue).equals("0")
}) })
o("can return boolean", function() { o("can return boolean", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return true return true
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("true") o(root.firstChild.nodeValue).equals("true")
}) })
o("can return falsy boolean", function() { o("can return falsy boolean", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return false return false
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.firstChild.nodeType).equals(3) o(root.firstChild.nodeType).equals(3)
o(root.firstChild.nodeValue).equals("") o(root.firstChild.nodeValue).equals("")
}) })
o("can return null", function() { o("can return null", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return null return null
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.childNodes.length).equals(0) o(root.childNodes.length).equals(0)
}) })
o("can return undefined", function() { o("can return undefined", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return undefined return undefined
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.childNodes.length).equals(0) o(root.childNodes.length).equals(0)
}) })
o("throws a custom error if it returns itself", function() { o("throws a custom error if it returns itself", function() {
// A view that returns its vnode would otherwise trigger an infinite loop // A view that returns its vnode would otherwise trigger an infinite loop
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return vnode return vnode
} }
} })
try { try {
render(root, [{tag: component}]) render(root, [{tag: component}])
} }
@ -277,14 +277,14 @@ o.spec("component", function() {
} }
}) })
o("can update when returning fragments", function() { o("can update when returning fragments", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return [ return [
{tag: "label"}, {tag: "label"},
{tag: "input"}, {tag: "input"},
] ]
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -293,11 +293,11 @@ o.spec("component", function() {
o(root.childNodes[1].nodeName).equals("INPUT") o(root.childNodes[1].nodeName).equals("INPUT")
}) })
o("can update when returning primitive", function() { o("can update when returning primitive", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return "a" return "a"
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -305,25 +305,25 @@ o.spec("component", function() {
o(root.firstChild.nodeValue).equals("a") o(root.firstChild.nodeValue).equals("a")
}) })
o("can update when returning null", function() { o("can update when returning null", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return null return null
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
render(root, [{tag: component}]) render(root, [{tag: component}])
o(root.childNodes.length).equals(0) o(root.childNodes.length).equals(0)
}) })
o("can remove when returning fragments", function() { o("can remove when returning fragments", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return [ return [
{tag: "label"}, {tag: "label"},
{tag: "input"}, {tag: "input"},
] ]
} }
} })
var div = {tag: "div", key: 2} var div = {tag: "div", key: 2}
render(root, [{tag: component, key: 1}, div]) render(root, [{tag: component, key: 1}, div])
@ -333,11 +333,11 @@ o.spec("component", function() {
o(root.firstChild).equals(div.dom) o(root.firstChild).equals(div.dom)
}) })
o("can remove when returning primitive", function() { o("can remove when returning primitive", function() {
var component = { var component = createComponent({
view: function(vnode) { view: function(vnode) {
return "a" return "a"
} }
} })
var div = {tag: "div", key: 2} var div = {tag: "div", key: 2}
render(root, [{tag: component, key: 1}, div]) render(root, [{tag: component, key: 1}, div])
@ -350,7 +350,7 @@ o.spec("component", function() {
o.spec("lifecycle", function() { o.spec("lifecycle", function() {
o("calls oninit", function() { o("calls oninit", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
oninit: function(vnode) { oninit: function(vnode) {
called++ called++
@ -361,7 +361,7 @@ o.spec("component", function() {
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
var node = {tag: component} var node = {tag: component}
render(root, [node]) render(root, [node])
@ -373,7 +373,7 @@ o.spec("component", function() {
}) })
o("calls oninit when returning fragment", function() { o("calls oninit when returning fragment", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
oninit: function(vnode) { oninit: function(vnode) {
called++ called++
@ -384,7 +384,7 @@ o.spec("component", function() {
view: function() { view: function() {
return [{tag: "div", attrs: {id: "a"}, text: "b"}] return [{tag: "div", attrs: {id: "a"}, text: "b"}]
} }
} })
var node = {tag: component} var node = {tag: component}
render(root, [node]) render(root, [node])
@ -411,12 +411,12 @@ o.spec("component", function() {
}) })
o("does not calls oninit on redraw", function() { o("does not calls oninit on redraw", function() {
var init = o.spy() var init = o.spy()
var component = { var component = createComponent({
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
}, },
oninit: init, oninit: init,
} })
function view() { function view() {
return {tag: component} return {tag: component}
@ -429,7 +429,7 @@ o.spec("component", function() {
}) })
o("calls oncreate", function() { o("calls oncreate", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
oncreate: function(vnode) { oncreate: function(vnode) {
called++ called++
@ -440,7 +440,7 @@ o.spec("component", function() {
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
var node = {tag: component} var node = {tag: component}
render(root, [node]) render(root, [node])
@ -452,12 +452,12 @@ o.spec("component", function() {
}) })
o("does not calls oncreate on redraw", function() { o("does not calls oncreate on redraw", function() {
var create = o.spy() var create = o.spy()
var component = { var component = createComponent({
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
}, },
oncreate: create, oncreate: create,
} })
function view() { function view() {
return {tag: component} return {tag: component}
@ -470,7 +470,7 @@ o.spec("component", function() {
}) })
o("calls oncreate when returning fragment", function() { o("calls oncreate when returning fragment", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
oncreate: function(vnode) { oncreate: function(vnode) {
called++ called++
@ -481,7 +481,7 @@ o.spec("component", function() {
view: function() { view: function() {
return [{tag: "div", attrs: {id: "a"}, text: "b"}] return [{tag: "div", attrs: {id: "a"}, text: "b"}]
} }
} })
var node = {tag: component} var node = {tag: component}
render(root, [node]) render(root, [node])
@ -493,7 +493,7 @@ o.spec("component", function() {
}) })
o("calls onupdate", function() { o("calls onupdate", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onupdate: function(vnode) { onupdate: function(vnode) {
called++ called++
@ -504,7 +504,7 @@ o.spec("component", function() {
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -519,7 +519,7 @@ o.spec("component", function() {
}) })
o("calls onupdate when returning fragment", function() { o("calls onupdate when returning fragment", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onupdate: function(vnode) { onupdate: function(vnode) {
called++ called++
@ -530,7 +530,7 @@ o.spec("component", function() {
view: function() { view: function() {
return [{tag: "div", attrs: {id: "a"}, text: "b"}] return [{tag: "div", attrs: {id: "a"}, text: "b"}]
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -545,7 +545,7 @@ o.spec("component", function() {
}) })
o("calls onremove", function() { o("calls onremove", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onremove: function(vnode) { onremove: function(vnode) {
called++ called++
@ -556,7 +556,7 @@ o.spec("component", function() {
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -569,7 +569,7 @@ o.spec("component", function() {
}) })
o("calls onremove when returning fragment", function() { o("calls onremove when returning fragment", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onremove: function(vnode) { onremove: function(vnode) {
called++ called++
@ -580,7 +580,7 @@ o.spec("component", function() {
view: function() { view: function() {
return [{tag: "div", attrs: {id: "a"}, text: "b"}] return [{tag: "div", attrs: {id: "a"}, text: "b"}]
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -593,7 +593,7 @@ o.spec("component", function() {
}) })
o("calls onbeforeremove", function() { o("calls onbeforeremove", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onbeforeremove: function(vnode) { onbeforeremove: function(vnode) {
called++ called++
@ -604,7 +604,7 @@ o.spec("component", function() {
view: function() { view: function() {
return {tag: "div", attrs: {id: "a"}, text: "b"} return {tag: "div", attrs: {id: "a"}, text: "b"}
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -617,7 +617,7 @@ o.spec("component", function() {
}) })
o("calls onbeforeremove when returning fragment", function() { o("calls onbeforeremove when returning fragment", function() {
var called = 0 var called = 0
var component = { var component = createComponent({
onbeforeremove: function(vnode) { onbeforeremove: function(vnode) {
called++ called++
@ -628,7 +628,7 @@ o.spec("component", function() {
view: function() { view: function() {
return [{tag: "div", attrs: {id: "a"}, text: "b"}] return [{tag: "div", attrs: {id: "a"}, text: "b"}]
} }
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -640,12 +640,12 @@ o.spec("component", function() {
o(root.childNodes.length).equals(0) o(root.childNodes.length).equals(0)
}) })
o("does not recycle when there's an onupdate", function() { o("does not recycle when there's an onupdate", function() {
var component = { var component = createComponent({
onupdate: function() {}, onupdate: function() {},
view: function() { view: function() {
return {tag: "div"} return {tag: "div"}
} }
} })
var update = o.spy() var update = o.spy()
var vnode = {tag: component, key: 1} var vnode = {tag: component, key: 1}
var updated = {tag: component, key: 1} var updated = {tag: component, key: 1}
@ -661,13 +661,13 @@ o.spec("component", function() {
o("initializes state", function() { o("initializes state", function() {
var called = 0 var called = 0
var data = {a: 1} var data = {a: 1}
var component = createComponent({ var component = createComponent(createComponent({
data: data, data: data,
oninit: init, oninit: init,
view: function() { view: function() {
return "" return ""
} }
}) }))
render(root, [{tag: component}]) render(root, [{tag: component}])
@ -679,13 +679,13 @@ o.spec("component", function() {
var called = 0 var called = 0
var body = {a: 1} var body = {a: 1}
var data = [body] var data = [body]
var component = createComponent({ var component = createComponent(createComponent({
data: data, data: data,
oninit: init, oninit: init,
view: function() { view: function() {
return "" return ""
} }
}) }))
render(root, [{tag: component}]) render(root, [{tag: component}])

View file

@ -176,11 +176,11 @@ o.spec("onbeforeremove", function() {
o("finalizes the remove phase asynchronously when promise is returned synchronously from both attrs- and tag.onbeforeremove", function(done) { o("finalizes the remove phase asynchronously when promise is returned synchronously from both attrs- and tag.onbeforeremove", function(done) {
var onremove = o.spy() var onremove = o.spy()
var onbeforeremove = function(){return Promise.resolve()} var onbeforeremove = function(){return Promise.resolve()}
var component = { var component = createComponent({
onbeforeremove: onbeforeremove, onbeforeremove: onbeforeremove,
onremove: onremove, onremove: onremove,
view: function() {}, view: function() {},
} })
render(root, [{tag: component, attrs: {onbeforeremove: onbeforeremove, onremove: onremove}}]) render(root, [{tag: component, attrs: {onbeforeremove: onbeforeremove, onremove: onremove}}])
render(root, []) render(root, [])
callAsync(function() { callAsync(function() {
@ -192,11 +192,11 @@ o.spec("onbeforeremove", function() {
var view = o.spy() var view = o.spy()
var onremove = o.spy() var onremove = o.spy()
var onbeforeremove = function(){return new Promise(function(resolve){callAsync(resolve)})} var onbeforeremove = function(){return new Promise(function(resolve){callAsync(resolve)})}
var component = { var component = createComponent({
onbeforeremove: onbeforeremove, onbeforeremove: onbeforeremove,
onremove: onremove, onremove: onremove,
view: view, view: view,
} })
render(root, [{tag: component}]) render(root, [{tag: component}])
render(root, []) render(root, [])

View file

@ -125,12 +125,12 @@ o.spec("onbeforeupdate", function() {
var createComponent = cmp.create var createComponent = cmp.create
o("prevents update in component", function() { o("prevents update in component", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return false}, onbeforeupdate: function() {return false},
view: function(vnode) { view: function(vnode) {
return {tag: "div", children: vnode.children} return {tag: "div", children: vnode.children}
}, },
} })
var vnode = {tag: component, children: [{tag: "#", children: "a"}]} var vnode = {tag: component, children: [{tag: "#", children: "a"}]}
var updated = {tag: component, children: [{tag: "#", children: "b"}]} var updated = {tag: component, children: [{tag: "#", children: "b"}]}
@ -141,12 +141,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("prevents update if returning false in component and false in vnode", function() { o("prevents update if returning false in component and false in vnode", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return false}, onbeforeupdate: function() {return false},
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: {id: vnode.attrs.id}} return {tag: "div", attrs: {id: vnode.attrs.id}}
}, },
} })
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}} var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}}
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}} var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}}
@ -157,12 +157,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("does not prevent update if returning true in component and true in vnode", function() { o("does not prevent update if returning true in component and true in vnode", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return true}, onbeforeupdate: function() {return true},
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: {id: vnode.attrs.id}} return {tag: "div", attrs: {id: vnode.attrs.id}}
}, },
} })
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}} var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}}
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}} var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}}
@ -173,12 +173,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("does not prevent update if returning false in component but true in vnode", function() { o("does not prevent update if returning false in component but true in vnode", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return false}, onbeforeupdate: function() {return false},
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: {id: vnode.attrs.id}} return {tag: "div", attrs: {id: vnode.attrs.id}}
}, },
} })
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}} var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}}
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}} var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}}
@ -189,12 +189,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("does not prevent update if returning true in component but false in vnode", function() { o("does not prevent update if returning true in component but false in vnode", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return true}, onbeforeupdate: function() {return true},
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: {id: vnode.attrs.id}} return {tag: "div", attrs: {id: vnode.attrs.id}}
}, },
} })
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}} var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}}
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}} var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}}
@ -205,12 +205,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("does not prevent update if returning true from component", function() { o("does not prevent update if returning true from component", function() {
var component = { var component = createComponent({
onbeforeupdate: function() {return true}, onbeforeupdate: function() {return true},
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs} return {tag: "div", attrs: vnode.attrs}
}, },
} })
var vnode = {tag: component, attrs: {id: "a"}} var vnode = {tag: component, attrs: {id: "a"}}
var updated = {tag: component, attrs: {id: "b"}} var updated = {tag: component, attrs: {id: "b"}}
@ -221,12 +221,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("accepts arguments for comparison in component", function() { o("accepts arguments for comparison in component", function() {
var component = { var component = createComponent({
onbeforeupdate: onbeforeupdate, onbeforeupdate: onbeforeupdate,
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs} return {tag: "div", attrs: vnode.attrs}
}, },
} })
var count = 0 var count = 0
var vnode = {tag: component, attrs: {id: "a"}} var vnode = {tag: component, attrs: {id: "a"}}
var updated = {tag: component, attrs: {id: "b"}} var updated = {tag: component, attrs: {id: "b"}}
@ -248,12 +248,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("is not called on component creation", function() { o("is not called on component creation", function() {
var component = { var component = createComponent({
onbeforeupdate: onbeforeupdate, onbeforeupdate: onbeforeupdate,
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs} return {tag: "div", attrs: vnode.attrs}
}, },
} })
var count = 0 var count = 0
var vnode = {tag: "div", attrs: {id: "a"}} var vnode = {tag: "div", attrs: {id: "a"}}
@ -270,12 +270,12 @@ o.spec("onbeforeupdate", function() {
}) })
o("is called only once on component update", function() { o("is called only once on component update", function() {
var component = { var component = createComponent({
onbeforeupdate: onbeforeupdate, onbeforeupdate: onbeforeupdate,
view: function(vnode) { view: function(vnode) {
return {tag: "div", attrs: vnode.attrs} return {tag: "div", attrs: vnode.attrs}
}, },
} })
var count = 0 var count = 0
var vnode = {tag: component, attrs: {id: "a"}} var vnode = {tag: component, attrs: {id: "a"}}