-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathscroll.test.ts
More file actions
34 lines (28 loc) · 1.01 KB
/
scroll.test.ts
File metadata and controls
34 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { buildScrollEvent } from '../scroll';
test('buildScrollEvent returns default scroll event', () => {
const event = buildScrollEvent();
expect(event.nativeEvent).toEqual({
contentInset: { bottom: 0, left: 0, right: 0, top: 0 },
contentOffset: { y: 0, x: 0 },
contentSize: { height: 0, width: 0 },
layoutMeasurement: { height: 0, width: 0 },
responderIgnoreScroll: true,
target: 0,
velocity: { y: 0, x: 0 },
});
});
test('buildScrollEvent uses provided offset', () => {
const event = buildScrollEvent({ y: 100, x: 50 });
expect(event.nativeEvent.contentOffset).toEqual({ y: 100, x: 50 });
});
test('buildScrollEvent uses provided options', () => {
const event = buildScrollEvent(
{ y: 0, x: 0 },
{
contentSize: { height: 1000, width: 400 },
layoutMeasurement: { height: 800, width: 400 },
},
);
expect(event.nativeEvent.contentSize).toEqual({ height: 1000, width: 400 });
expect(event.nativeEvent.layoutMeasurement).toEqual({ height: 800, width: 400 });
});