-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathcommon.test.ts
More file actions
57 lines (47 loc) · 1.5 KB
/
common.test.ts
File metadata and controls
57 lines (47 loc) · 1.5 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {
buildBlurEvent,
buildFocusEvent,
buildResponderGrantEvent,
buildResponderReleaseEvent,
buildTouchEvent,
} from '../common';
test('buildTouchEvent returns event with touch nativeEvent', () => {
const event = buildTouchEvent();
expect(event.nativeEvent).toEqual({
changedTouches: [],
identifier: 0,
locationX: 0,
locationY: 0,
pageX: 0,
pageY: 0,
target: 0,
timestamp: expect.any(Number),
touches: [],
});
expect(event.currentTarget).toHaveProperty('measure');
expect(event).toHaveProperty('preventDefault');
});
test('buildResponderGrantEvent returns touch event with dispatchConfig', () => {
const event = buildResponderGrantEvent();
expect(event.dispatchConfig).toEqual({
registrationName: 'onResponderGrant',
});
expect(event.nativeEvent).toHaveProperty('touches');
});
test('buildResponderReleaseEvent returns touch event with dispatchConfig', () => {
const event = buildResponderReleaseEvent();
expect(event.dispatchConfig).toEqual({
registrationName: 'onResponderRelease',
});
expect(event.nativeEvent).toHaveProperty('touches');
});
test('buildFocusEvent returns event with target', () => {
const event = buildFocusEvent();
expect(event.nativeEvent).toEqual({ target: 0 });
expect(event).toHaveProperty('preventDefault');
});
test('buildBlurEvent returns event with target', () => {
const event = buildBlurEvent();
expect(event.nativeEvent).toEqual({ target: 0 });
expect(event).toHaveProperty('preventDefault');
});