Tests: Wrap some component definitions in createComponent() calls

These are the ones that would have been tedious to automate.
jscodeshift will handle the remaining ones
This commit is contained in:
Pierre-Yves Gerardy 2017-02-19 01:18:02 +01:00
parent 90b67b42f0
commit ac38335453
5 changed files with 43 additions and 43 deletions

View file

@ -397,7 +397,7 @@ o.spec("component", function() {
o("calls oninit before view", function() {
var viewCalled = false
render(root, {
render(root, createComponent({
tag: {
view: function() {
viewCalled = true
@ -407,7 +407,7 @@ o.spec("component", function() {
o(viewCalled).equals(false)
},
}
})
}))
})
o("does not calls oninit on redraw", function() {
var init = o.spy()
@ -661,13 +661,13 @@ o.spec("component", function() {
o("initializes state", function() {
var called = 0
var data = {a: 1}
var component = {
var component = createComponent({
data: data,
oninit: init,
view: function() {
return ""
}
}
})
render(root, [{tag: component}])
@ -679,13 +679,13 @@ o.spec("component", function() {
var called = 0
var body = {a: 1}
var data = [body]
var component = {
var component = createComponent({
data: data,
oninit: init,
view: function() {
return ""
}
}
})
render(root, [{tag: component}])

View file

@ -119,16 +119,16 @@ o.spec("onremove", function() {
o("calls onremove on nested component", function() {
var spy = o.spy()
var comp = {
var comp = createComponent({
view: function() {return m(outer)}
}
var outer = {
})
var outer = createComponent({
view: function() {return m(inner)}
}
var inner = {
})
var inner = createComponent({
onremove: spy,
view: function() {return m("div")}
}
})
render(root, {tag: comp})
render(root, null)
@ -136,15 +136,15 @@ o.spec("onremove", function() {
})
o("calls onremove on nested component child", function() {
var spy = o.spy()
var comp = {
var comp = createComponent({
view: function() {return m(outer)}
}
var outer = {
})
var outer = createComponent({
view: function() {return m(inner, m("a", {onremove: spy}))}
}
var inner = {
})
var inner = createComponent({
view: function(vnode) {return m("div", vnode.children)}
}
})
render(root, {tag: comp})
render(root, null)

View file

@ -910,7 +910,7 @@ o.spec("updateNodes", function() {
var createComponent = cmp.create
o("fragment child toggles from null when followed by null component then tag", function() {
var component = {view: function() {return null}}
var component = createComponent({view: function() {return null}})
var vnodes = [{tag: "[", children: [{tag: "a"}, {tag: component}, {tag: "b"}]}]
var temp = [{tag: "[", children: [null, {tag: component}, {tag: "b"}]}]
var updated = [{tag: "[", children: [{tag: "a"}, {tag: component}, {tag: "b"}]}]
@ -925,8 +925,8 @@ o.spec("updateNodes", function() {
})
o("fragment child toggles from null in component when followed by null component then tag", function() {
var flag = true
var a = {view: function() {return flag ? {tag: "a"} : null}}
var b = {view: function() {return null}}
var a = createComponent({view: function() {return flag ? {tag: "a"} : null}})
var b = createComponent({view: function() {return null}})
var vnodes = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]
var temp = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]
var updated = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]