Skip to content

Commit a6914a1

Browse files
committed
test: origin scroll
1 parent 2a00a14 commit a6914a1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/touch.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,40 @@ describe('List.Touch', () => {
9494
wrapper.unmount();
9595
});
9696

97+
it('origin scroll', () => {
98+
const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100) });
99+
100+
function getElement() {
101+
return wrapper.find('.rc-virtual-list-holder').instance();
102+
}
103+
104+
act(() => {
105+
// start
106+
const touchEvent = new Event('touchstart');
107+
touchEvent.touches = [{ pageY: 100 }];
108+
getElement().dispatchEvent(touchEvent);
109+
110+
// move
111+
const moveEvent1 = new Event('touchmove');
112+
moveEvent1.touches = [{ pageY: 110 }];
113+
getElement().dispatchEvent(moveEvent1);
114+
115+
// move
116+
const moveEvent2 = new Event('touchmove');
117+
moveEvent2.touches = [{ pageY: 150 }];
118+
getElement().dispatchEvent(moveEvent2);
119+
120+
// end
121+
const endEvent = new Event('touchend');
122+
getElement().dispatchEvent(endEvent);
123+
124+
// smooth
125+
jest.runAllTimers();
126+
});
127+
expect(wrapper.find('ul').instance().scrollTop).toBe(0);
128+
wrapper.unmount();
129+
});
130+
97131
it('not call when not scroll-able', () => {
98132
const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100) });
99133

0 commit comments

Comments
 (0)