Tests: render/test-components tweaks
This commit is contained in:
parent
f96319e6f6
commit
90b67b42f0
1 changed files with 29 additions and 9 deletions
|
|
@ -658,7 +658,7 @@ o.spec("component", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
o.spec("state", function() {
|
o.spec("state", function() {
|
||||||
o("copies state", function() {
|
o("initializes state", function() {
|
||||||
var called = 0
|
var called = 0
|
||||||
var data = {a: 1}
|
var data = {a: 1}
|
||||||
var component = {
|
var component = {
|
||||||
|
|
@ -672,15 +672,10 @@ o.spec("component", function() {
|
||||||
render(root, [{tag: component}])
|
render(root, [{tag: component}])
|
||||||
|
|
||||||
function init(vnode) {
|
function init(vnode) {
|
||||||
o(vnode.state.data).deepEquals(data)
|
|
||||||
o(vnode.state.data).equals(data)
|
o(vnode.state.data).equals(data)
|
||||||
|
|
||||||
//inherits state via prototype
|
|
||||||
component.x = 1
|
|
||||||
o(vnode.state.x).equals(1)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
o("state copy is shallow", function() {
|
o('state "copy" is shallow', function() {
|
||||||
var called = 0
|
var called = 0
|
||||||
var body = {a: 1}
|
var body = {a: 1}
|
||||||
var data = [body]
|
var data = [body]
|
||||||
|
|
@ -702,7 +697,32 @@ o.spec("component", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
o.spec("Alternative ways to specify components", function() {
|
o.spec("Tests specific to certain component kinds", function() {
|
||||||
|
|
||||||
|
o.spec("POJO state", function() {
|
||||||
|
o("copies state", function() {
|
||||||
|
var called = 0
|
||||||
|
var data = {a: 1}
|
||||||
|
var component = {
|
||||||
|
data: data,
|
||||||
|
oninit: init,
|
||||||
|
view: function() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
|
||||||
|
function init(vnode) {
|
||||||
|
o(vnode.state.data).equals(data)
|
||||||
|
|
||||||
|
//inherits state via prototype
|
||||||
|
component.x = 1
|
||||||
|
o(vnode.state.x).equals(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
o("Classes can be used as components", function() {
|
o("Classes can be used as components", function() {
|
||||||
function MyComponent(vnode){
|
function MyComponent(vnode){
|
||||||
o(vnode.state).equals(null)
|
o(vnode.state).equals(null)
|
||||||
|
|
@ -769,7 +789,7 @@ o.spec("component", function() {
|
||||||
o(proto.onbeforeremove.args.length).equals(1)
|
o(proto.onbeforeremove.args.length).equals(1)
|
||||||
o(proto.onremove.args.length).equals(1)
|
o(proto.onremove.args.length).equals(1)
|
||||||
})
|
})
|
||||||
o("Factory functions can be used as components", function() {
|
o("Closure functions can be used as components", function() {
|
||||||
var state, context
|
var state, context
|
||||||
function component(vnode) {
|
function component(vnode) {
|
||||||
o(vnode.state).equals(null)
|
o(vnode.state).equals(null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue