Skip to content

Commit a7a546a

Browse files
authored
Merge pull request #1173 from pygy/multi-mount-redraw-test
Test for #1146 and #1153
2 parents 2cfc985 + 357de85 commit a7a546a

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

api/tests/test-mount.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,71 @@ o.spec("mount", function() {
6868
}, FRAME_BUDGET)
6969
})
7070

71+
o("redraws several mount points on events", function(done) {
72+
var onupdate0 = o.spy()
73+
var oninit0 = o.spy()
74+
var onclick0 = o.spy()
75+
var onupdate1 = o.spy()
76+
var oninit1 = o.spy()
77+
var onclick1 = o.spy()
78+
79+
var e = $window.document.createEvent("MouseEvents")
80+
81+
e.initEvent("click", true, true)
82+
83+
render(root, [
84+
m("#child0"),
85+
m("#child1")
86+
])
87+
88+
mount(root.childNodes[0], {
89+
view : function() {
90+
return m("div", {
91+
oninit : oninit0,
92+
onupdate : onupdate0,
93+
onclick : onclick0,
94+
})
95+
}
96+
})
97+
98+
o(oninit0.callCount).equals(1)
99+
o(onupdate0.callCount).equals(0)
100+
101+
mount(root.childNodes[1], {
102+
view : function() {
103+
return m("div", {
104+
oninit : oninit1,
105+
onupdate : onupdate1,
106+
onclick : onclick1,
107+
})
108+
}
109+
})
110+
111+
o(oninit1.callCount).equals(1)
112+
o(onupdate1.callCount).equals(0)
113+
114+
root.childNodes[0].firstChild.dispatchEvent(e)
115+
o(onclick0.callCount).equals(1)
116+
o(onclick0.this).equals(root.childNodes[0].firstChild)
117+
118+
setTimeout(function() {
119+
o(onupdate0.callCount).equals(1)
120+
o(onupdate1.callCount).equals(1)
121+
122+
root.childNodes[1].firstChild.dispatchEvent(e)
123+
o(onclick1.callCount).equals(1)
124+
o(onclick1.this).equals(root.childNodes[1].firstChild)
125+
126+
setTimeout(function() {
127+
o(onupdate0.callCount).equals(2)
128+
o(onupdate1.callCount).equals(2)
129+
130+
done()
131+
}, FRAME_BUDGET)
132+
}, FRAME_BUDGET)
133+
134+
})
135+
71136
o("event handlers can skip redraw", function(done) {
72137
var onupdate = o.spy()
73138
var oninit = o.spy()

0 commit comments

Comments
 (0)