-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathcommon.ts
71 lines (66 loc) · 1.64 KB
/
common.ts
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Experimental values:
* - iOS: `{"changedTouches": [[Circular]], "identifier": 1, "locationX": 253, "locationY": 30.333328247070312, "pageX": 273, "pageY": 141.3333282470703, "target": 75, "timestamp": 875928682.0450834, "touches": [[Circular]]}`
* - Android: `{"changedTouches": [[Circular]], "identifier": 0, "locationX": 160, "locationY": 40.3636360168457, "pageX": 180, "pageY": 140.36363220214844, "target": 53, "targetSurface": -1, "timestamp": 10290805, "touches": [[Circular]]}`
*/
function touch() {
return {
nativeEvent: {
changedTouches: [],
identifier: 0,
locationX: 0,
locationY: 0,
pageX: 0,
pageY: 0,
target: 0,
timestamp: Date.now(),
touches: [],
},
persist: jest.fn(),
currentTarget: { measure: jest.fn() },
target: {},
};
}
export const CommonEventBuilder = {
touch,
responderGrant: () => {
return {
...touch(),
dispatchConfig: { registrationName: 'onResponderGrant' },
};
},
responderRelease: () => {
return {
...touch(),
dispatchConfig: { registrationName: 'onResponderRelease' },
};
},
/**
* Experimental values:
* - iOS: `{"eventCount": 0, "target": 75, "text": ""}`
* - Android: `{"target": 53}`
*/
focus: () => {
return {
nativeEvent: {
target: 0,
},
currentTarget: {},
target: {},
};
},
/**
* Experimental values:
* - iOS: `{"eventCount": 0, "target": 75, "text": ""}`
* - Android: `{"target": 53}`
*/
blur: () => {
return {
nativeEvent: {
target: 0,
},
currentTarget: {},
target: {},
};
},
};