Support classes and factories as components (#1339)
* Support classes and factories as components * Tests for class and factory component support
This commit is contained in:
parent
ff16c7f47a
commit
3f3af74dde
5 changed files with 301 additions and 16 deletions
|
|
@ -424,7 +424,7 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
})
|
||||
o.spec("components", function() {
|
||||
o("works", function() {
|
||||
o("works with POJOs", function() {
|
||||
var component = {
|
||||
view: function() {
|
||||
return m("div")
|
||||
|
|
@ -432,6 +432,19 @@ o.spec("hyperscript", function() {
|
|||
}
|
||||
var vnode = m(component, {id: "a"}, "b")
|
||||
|
||||
o(vnode.tag).equals(component)
|
||||
o(vnode.attrs.id).equals("a")
|
||||
o(vnode.children.length).equals(1)
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals("b")
|
||||
})
|
||||
o("works with functions", function() {
|
||||
var component = o.spy()
|
||||
|
||||
var vnode = m(component, {id: "a"}, "b")
|
||||
|
||||
o(component.callCount).equals(0)
|
||||
|
||||
o(vnode.tag).equals(component)
|
||||
o(vnode.attrs.id).equals("a")
|
||||
o(vnode.children.length).equals(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue