Skip to content

Commit 7f793bb

Browse files
committed
scrolling callbacks calls;
1 parent 07e57fa commit 7f793bb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/Scrollbars/scrolling.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default function createTests(scrollbarWidth) {
3131

3232
expect(updateSpy.callCount).toBe(1);
3333
expect(renderSpy.callCount).toBe(0);
34+
35+
updateSpy.restore();
36+
renderSpy.restore();
3437
done();
3538
});
3639
});
@@ -45,6 +48,16 @@ export default function createTests(scrollbarWidth) {
4548
this.scrollTop = 50;
4649
setTimeout(() => {
4750
expect(spy.callCount).toBe(1);
51+
expect(spy.getCall(0).args[0]).toMatchObject({
52+
left: 0,
53+
top: 0.5,
54+
scrollLeft: 0,
55+
scrollTop: 50,
56+
scrollHeight: 200,
57+
scrollWidth: 200,
58+
clientWidth: 100,
59+
clientHeight: 100,
60+
});
4861
done();
4962
}, 50);
5063
});
@@ -95,6 +108,26 @@ export default function createTests(scrollbarWidth) {
95108
});
96109

97110
describe("when scrolling horizontally", function () {
111+
it("should not trigger a rerender", (done) => {
112+
render(<Scrollbar style={ {width: 100, height: 100} } gridless>
113+
<div style={ {width: 200, height: 200} }></div>
114+
</Scrollbar>,
115+
node,
116+
function () {
117+
const updateSpy = sinon.spy(Scrollbar.prototype, 'update');
118+
const renderSpy = sinon.spy(Scrollbar.prototype, 'render');
119+
120+
this.scrollTop = 50;
121+
122+
expect(updateSpy.callCount).toBe(1);
123+
expect(renderSpy.callCount).toBe(0);
124+
125+
updateSpy.restore();
126+
renderSpy.restore();
127+
done();
128+
});
129+
});
130+
98131
it("onScroll should be called", (done) => {
99132
const spy = sinon.spy();
100133
render(<Scrollbar style={ {width: 100, height: 100} } onScroll={ spy } gridless>
@@ -105,6 +138,16 @@ export default function createTests(scrollbarWidth) {
105138
this.scrollLeft = 50;
106139
setTimeout(() => {
107140
expect(spy.callCount).toBe(1);
141+
expect(spy.getCall(0).args[0]).toMatchObject({
142+
top: 0,
143+
left: 0.5,
144+
scrollTop: 0,
145+
scrollLeft: 50,
146+
scrollHeight: 200,
147+
scrollWidth: 200,
148+
clientWidth: 100,
149+
clientHeight: 100,
150+
});
108151
done();
109152
}, 50);
110153
});

0 commit comments

Comments
 (0)