Tests for mounting class and factory components

This commit is contained in:
Pierre-Yves Gerardy 2017-02-15 16:43:29 +01:00
parent 3f3af74dde
commit 9e65e6bf47

View file

@ -32,7 +32,17 @@ o.spec("mount", function() {
o(threw).equals(true) o(threw).equals(true)
}) })
o("renders into `root`", function() { o("throws on invalid component", function() {
var threw = false
try {
mount(root, {})
} catch (e) {
threw = true
}
o(threw).equals(true)
})
o("renders into `root` (POJO component)", function() {
mount(root, { mount(root, {
view : function() { view : function() {
return m("div") return m("div")
@ -42,6 +52,26 @@ o.spec("mount", function() {
o(root.firstChild.nodeName).equals("DIV") o(root.firstChild.nodeName).equals("DIV")
}) })
o("renders into `root` (class component)", function() {
function Cmp(){}
Cmp.prototype.view = function(){return m("div")}
mount(root, Cmp)
o(root.firstChild.nodeName).equals("DIV")
})
o("renders into `root` factory (factory component)", function() {
mount(root, function(){
return {
view : function() {
return m("div")
}
}
})
o(root.firstChild.nodeName).equals("DIV")
})
o("mounting null unmounts", function() { o("mounting null unmounts", function() {
mount(root, { mount(root, {
view : function() { view : function() {