forked from maplibre/maplibre-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-jest.js
108 lines (102 loc) · 3.1 KB
/
setup-jest.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {NativeModules} from 'react-native';
function keyMirror(keys) {
const obj = {};
keys.forEach(key => (obj[key] = key));
return obj;
}
// Mock of what the native code puts on the JS object
NativeModules.MLNModule = {
// constants
UserTrackingModes: keyMirror([
'None',
'Follow',
'FollowWithCourse',
'FollowWithHeading',
]),
StyleURL: keyMirror(['Default']),
EventTypes: keyMirror([
'MapClick',
'MapLongClick',
'RegionWillChange',
'RegionIsChanging',
'RegionDidChange',
'WillStartLoadingMap',
'DidFinishLoadingMap',
'DidFailLoadingMap',
'WillStartRenderingFrame',
'DidFinishRenderingFrame',
'DidFinishRenderingFrameFully',
'DidFinishLoadingStyle',
'SetCameraComplete',
]),
CameraModes: keyMirror(['Flight', 'Ease', 'None']),
StyleSource: keyMirror(['DefaultSourceID']),
InterpolationMode: keyMirror([
'Exponential',
'Categorical',
'Interval',
'Identity',
]),
LineJoin: keyMirror(['Bevel', 'Round', 'Miter']),
LineCap: keyMirror(['Butt', 'Round', 'Square']),
LineTranslateAnchor: keyMirror(['Map', 'Viewport']),
CirclePitchScale: keyMirror(['Map', 'Viewport']),
CircleTranslateAnchor: keyMirror(['Map', 'Viewport']),
FillExtrusionTranslateAnchor: keyMirror(['Map', 'Viewport']),
FillTranslateAnchor: keyMirror(['Map', 'Viewport']),
IconRotationAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
IconTextFit: keyMirror(['None', 'Width', 'Height', 'Both']),
IconTranslateAnchor: keyMirror(['Map', 'Viewport']),
SymbolPlacement: keyMirror(['Line', 'Point']),
TextAnchor: keyMirror([
'Center',
'Left',
'Right',
'Top',
'Bottom',
'TopLeft',
'TopRight',
'BottomLeft',
'BottomRight',
]),
TextJustify: keyMirror(['Center', 'Left', 'Right']),
TextPitchAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
TextRotationAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
TextTransform: keyMirror(['None', 'Lowercase', 'Uppercase']),
TextTranslateAnchor: keyMirror(['Map', 'Viewport']),
LightAnchor: keyMirror(['Map', 'Viewport']),
OfflinePackDownloadState: keyMirror(['Inactive', 'Active', 'Complete']),
OfflineCallbackName: keyMirror(['Progress', 'Error']),
// methods
setAccessToken: jest.fn(),
getAccessToken: () => Promise.resolve('test-token'),
setConnected: jest.fn(),
};
NativeModules.MLNOfflineModule = {
createPack: packOptions => {
return Promise.resolve({
bounds: packOptions.bounds,
metadata: JSON.stringify({name: packOptions.name}),
});
},
getPacks: () => Promise.resolve([]),
deletePack: () => Promise.resolve(),
getPackStatus: () => Promise.resolve({}),
pausePackDownload: () => Promise.resolve(),
resumePackDownload: () => Promise.resolve(),
setPackObserver: () => Promise.resolve(),
setTileCountLimit: jest.fn(),
setProgressEventThrottle: jest.fn(),
};
NativeModules.MLNSnapshotModule = {
takeSnap: () => {
return Promise.resolve('file://test.png');
},
};
NativeModules.MLNLocationModule = {
getLastKnownLocation: jest.fn(),
setMinDisplacement: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
pause: jest.fn(),
};