Tests use hyperscript instead of manually constructing nodes
This commit is contained in:
parent
5502570b16
commit
31d2ed4be8
27 changed files with 1515 additions and 1841 deletions
|
|
@ -1,10 +1,12 @@
|
|||
"use strict"
|
||||
|
||||
var m = require("../render/hyperscript")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
kind: "POJO",
|
||||
create: function(methods) {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
var res = {view: function() {return m("div")}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
|
|
@ -12,7 +14,7 @@ module.exports = [
|
|||
kind: "constructible",
|
||||
create: function(methods) {
|
||||
function res(){}
|
||||
res.prototype.view = function() {return {tag:"div"}}
|
||||
res.prototype.view = function() {return m("div")}
|
||||
Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
|
|
@ -20,7 +22,7 @@ module.exports = [
|
|||
kind: "closure",
|
||||
create: function(methods) {
|
||||
return function() {
|
||||
var res = {view: function() {return {tag:"div"}}}
|
||||
var res = {view: function() {return m("div")}}
|
||||
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
var o = require("ospec")
|
||||
var components = require("../../test-utils/components")
|
||||
var m = require("../../render/hyperscript")
|
||||
|
||||
o.spec("test-utils/components", function() {
|
||||
var test = o.spy(function(component) {
|
||||
|
|
@ -32,7 +33,7 @@ o.spec("test-utils/components", function() {
|
|||
var vnode = cmp1.view()
|
||||
|
||||
o(vnode != null).equals(true)
|
||||
o(vnode).deepEquals({tag: "div"})
|
||||
o(vnode).deepEquals(m("div"))
|
||||
|
||||
if (component.kind !== "constructible") {
|
||||
o(cmp2).deepEquals(methods)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue