Add test-utils/components.js and its tests

This commit is contained in:
Pierre-Yves Gerardy 2017-02-18 23:05:17 +01:00
parent 1a6554423d
commit eccea68212
3 changed files with 83 additions and 0 deletions

27
test-utils/components.js Normal file
View file

@ -0,0 +1,27 @@
module.exports = [
{
kind: 'POJO',
create: function(methods) {
var res = {view: function() {return {tag:'div'}}}
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
return res
}
}, {
kind: 'constructible',
create: function(methods) {
function res(){}
res.prototype.view = function() {return {tag:'div'}}
Object.keys(methods || {}).forEach(function(m){res.prototype[m] = methods[m]})
return res
}
}, {
kind: 'closure',
create: function(methods) {
return function() {
var res = {view: function() {return {tag:'div'}}}
Object.keys(methods || {}).forEach(function(m){res[m] = methods[m]})
return res
}
}
}
]