@maplibre/maplibre-react-native 10.0.0-alpha.20 → 10.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ["universe/native"],
4
+ ignorePatterns: ["build"],
5
+ };
@@ -0,0 +1,3 @@
1
+ # style: apply formatting via lint:fix
2
+ # https://github.com/maplibre/maplibre-react-native/pull/467
3
+ 017b3861ae8ac856a3b032ebea6497eff4420e1f
package/CHANGELOG.md CHANGED
@@ -6,6 +6,23 @@ PR Title ([#123](link to my pr))
6
6
 
7
7
  ```
8
8
 
9
+ ## 10.0.0-alpha.22
10
+
11
+ chore: configure jest to use with ts
12
+ ([#470](https://github.com/maplibre/maplibre-react-native/pull/470))
13
+
14
+ refactor: switch many examples to TypeScript
15
+ ([#469](https://github.com/maplibre/maplibre-react-native/pull/469))
16
+
17
+ chore: eslint formatting and improve scripts
18
+ ([#467](https://github.com/maplibre/maplibre-react-native/pull/467))
19
+
20
+ fix: allow resetting contentInset with 0 ([#468](https://github.com/maplibre/maplibre-react-native/pull/468))
21
+
22
+ ## 10.0.0-alpha.21
23
+
24
+ fix: Call requestProgress when getting pack status on IOS + example improvement [#445](https://github.com/maplibre/maplibre-react-native/pull/445)
25
+
9
26
  ## 10.0.0-alpha.20
10
27
 
11
28
  fix: fix style expressions, revert changes to scripts/autogenHelpers/globals.js ([#466](https://github.com/maplibre/maplibre-react-native/pull/466))
package/app.plugin.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./plugin/build/withMapLibre');
1
+ module.exports = require("./plugin/build/withMapLibre");
package/babel.config.js CHANGED
@@ -1,9 +1,12 @@
1
1
  module.exports = {
2
- presets: ['module:metro-react-native-babel-preset'],
3
- plugins: [['@babel/plugin-proposal-class-properties', {loose: true}]],
2
+ presets: ["module:metro-react-native-babel-preset"],
3
+ plugins: [
4
+ ["@babel/plugin-proposal-class-properties", { loose: true }],
5
+ ["@babel/plugin-transform-private-methods", { loose: true }],
6
+ ],
4
7
  env: {
5
8
  production: {
6
- plugins: ['transform-remove-console'],
9
+ plugins: ["transform-remove-console"],
7
10
  },
8
11
  },
9
12
  };
@@ -48,12 +48,12 @@ NSString *const RCT_MAPBOX_OFFLINE_CALLBACK_ERROR = @"MapboOfflineRegionError";
48
48
  packRequestQueue = [NSMutableArray new];
49
49
  eventThrottle = 300;
50
50
  lastPackState = -1;
51
-
51
+
52
52
  NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
53
53
  [defaultCenter addObserver:self selector:@selector(offlinePackProgressDidChange:) name:MLNOfflinePackProgressChangedNotification object:nil];
54
54
  [defaultCenter addObserver:self selector:@selector(offlinePackDidReceiveError:) name:MLNOfflinePackErrorNotification object:nil];
55
55
  [defaultCenter addObserver:self selector:@selector(offlinePackDidReceiveMaxAllowedMapboxTiles:) name:MLNOfflinePackMaximumMapboxTilesReachedNotification object:nil];
56
-
56
+
57
57
  [[MLNOfflineStorage sharedOfflineStorage] addObserver:self forKeyPath:@"packs" options:NSKeyValueObservingOptionInitial context:NULL];
58
58
  }
59
59
  return self;
@@ -72,15 +72,21 @@ NSString *const RCT_MAPBOX_OFFLINE_CALLBACK_ERROR = @"MapboOfflineRegionError";
72
72
 
73
73
  - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
74
74
  {
75
+ if ([keyPath isEqualToString:@"state"] && [object isKindOfClass:[MLNOfflinePack class]]) {
76
+ MLNOfflinePack* pack = (MLNOfflinePack*)object;
77
+ [self observerStateForPack:pack context:context];
78
+ return;
79
+ }
80
+
75
81
  if (packRequestQueue.count == 0) {
76
82
  return;
77
83
  }
78
-
84
+
79
85
  NSArray<MLNOfflinePack *> *packs = [[MLNOfflineStorage sharedOfflineStorage] packs];
80
86
  if (packs == nil) {
81
87
  return;
82
88
  }
83
-
89
+
84
90
  while (packRequestQueue.count > 0) {
85
91
  RCTPromiseResolveBlock resolve = [packRequestQueue objectAtIndex:0];
86
92
  resolve([self _convertPacksToJson:packs]);
@@ -94,13 +100,13 @@ RCT_EXPORT_METHOD(createPack:(NSDictionary *)options
94
100
  {
95
101
  NSString *styleURL = options[@"styleURL"];
96
102
  MLNCoordinateBounds bounds = [RCTMLNUtils fromFeatureCollection:options[@"bounds"]];
97
-
103
+
98
104
  id<MLNOfflineRegion> offlineRegion = [[MLNTilePyramidOfflineRegion alloc] initWithStyleURL:[NSURL URLWithString:styleURL]
99
105
  bounds:bounds
100
106
  fromZoomLevel:[options[@"minZoom"] doubleValue]
101
107
  toZoomLevel:[options[@"maxZoom"] doubleValue]];
102
108
  NSData *context = [self _archiveMetadata:options[@"metadata"]];
103
-
109
+
104
110
  [[MLNOfflineStorage sharedOfflineStorage] addPackForRegion:offlineRegion
105
111
  withContext:context
106
112
  completionHandler:^(MLNOfflinePack *pack, NSError *error) {
@@ -129,7 +135,7 @@ RCT_EXPORT_METHOD(mergeOfflineRegions:(NSString *)path
129
135
  return reject(@"asset_does_not_exist", [NSString stringWithFormat:@"The given assetName, %@, can't be found in the app's bundle.", path], nil);
130
136
  }
131
137
  }
132
-
138
+
133
139
  [[MLNOfflineStorage sharedOfflineStorage] addContentsOfFile:absolutePath withCompletionHandler:^(NSURL *fileURL, NSArray<MLNOfflinePack *> *packs, NSError *error) {
134
140
  if (error != nil) {
135
141
  reject(@"mergeOfflineRegions", error.description, error);
@@ -143,7 +149,7 @@ RCT_EXPORT_METHOD(getPacks:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseR
143
149
  {
144
150
  dispatch_async(dispatch_get_main_queue(), ^{
145
151
  NSArray<MLNOfflinePack *> *packs = [[MLNOfflineStorage sharedOfflineStorage] packs];
146
-
152
+
147
153
  if (packs == nil) {
148
154
  // packs have not loaded yet
149
155
  [self->packRequestQueue addObject:resolve];
@@ -187,7 +193,7 @@ RCT_EXPORT_METHOD(setMaximumAmbientCacheSize:(NSUInteger)cacheSize
187
193
  }
188
194
  resolve(nil);
189
195
  }];
190
-
196
+
191
197
  }
192
198
 
193
199
  RCT_EXPORT_METHOD(resetDatabase:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
@@ -199,7 +205,7 @@ RCT_EXPORT_METHOD(resetDatabase:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
199
205
  }
200
206
  resolve(nil);
201
207
  }];
202
-
208
+
203
209
  }
204
210
 
205
211
  RCT_EXPORT_METHOD(getPackStatus:(NSString *)name
@@ -207,14 +213,29 @@ RCT_EXPORT_METHOD(getPackStatus:(NSString *)name
207
213
  rejecter:(RCTPromiseRejectBlock)reject)
208
214
  {
209
215
  MLNOfflinePack *pack = [self _getPackFromName:name];
210
-
216
+
211
217
  if (pack == nil) {
212
218
  resolve(nil);
213
219
  NSLog(@"getPackStatus - Unknown offline region");
214
220
  return;
215
221
  }
216
-
217
- resolve([self _makeRegionStatusPayload:name pack:pack]);
222
+
223
+ if (pack.state == MLNOfflinePackStateUnknown) {
224
+ [pack addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:(__bridge_retained void*)resolve];
225
+ [pack requestProgress];
226
+ } else {
227
+ resolve([self _makeRegionStatusPayload:name pack:pack]);
228
+ }
229
+ }
230
+
231
+ -(void)observerStateForPack:(MLNOfflinePack*)pack context:(nullable void*) context {
232
+ RCTPromiseResolveBlock resolve = (__bridge_transfer RCTPromiseResolveBlock)context;
233
+ dispatch_async(dispatch_get_main_queue(), ^{
234
+ NSDictionary* metadata = [self _unarchiveMetadata:pack];
235
+ NSString* name = metadata[@"name"];
236
+ resolve([self _makeRegionStatusPayload:name pack:pack]);
237
+ });
238
+ [pack removeObserver:self forKeyPath:@"state" context:context];
218
239
  }
219
240
 
220
241
  RCT_EXPORT_METHOD(invalidatePack:(NSString *)name
@@ -241,7 +262,7 @@ RCT_EXPORT_METHOD(deletePack:(NSString *)name
241
262
  rejecter:(RCTPromiseRejectBlock)reject)
242
263
  {
243
264
  MLNOfflinePack *pack = [self _getPackFromName:name];
244
-
265
+
245
266
  if (pack == nil) {
246
267
  resolve(nil);
247
268
  return;
@@ -265,17 +286,17 @@ RCT_EXPORT_METHOD(pausePackDownload:(NSString *)name
265
286
  rejecter:(RCTPromiseRejectBlock)reject)
266
287
  {
267
288
  MLNOfflinePack *pack = [self _getPackFromName:name];
268
-
289
+
269
290
  if (pack == nil) {
270
291
  reject(@"pausePackDownload", @"Unknown offline region", nil);
271
292
  return;
272
293
  }
273
-
294
+
274
295
  if (pack.state == MLNOfflinePackStateInactive || pack.state == MLNOfflinePackStateComplete) {
275
296
  resolve(nil);
276
297
  return;
277
298
  }
278
-
299
+
279
300
  [pack suspend];
280
301
  resolve(nil);
281
302
  }
@@ -285,17 +306,17 @@ RCT_EXPORT_METHOD(resumePackDownload:(NSString *)name
285
306
  rejecter:(RCTPromiseRejectBlock)reject)
286
307
  {
287
308
  MLNOfflinePack *pack = [self _getPackFromName:name];
288
-
309
+
289
310
  if (pack == nil) {
290
311
  reject(@"resumePack", @"Unknown offline region", nil);
291
312
  return;
292
313
  }
293
-
314
+
294
315
  if (pack.state == MLNOfflinePackStateActive || pack.state == MLNOfflinePackStateComplete) {
295
316
  resolve(nil);
296
317
  return;
297
318
  }
298
-
319
+
299
320
  [pack resume];
300
321
  resolve(nil);
301
322
  }
@@ -313,18 +334,18 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
313
334
  - (void)offlinePackProgressDidChange:(NSNotification *)notification
314
335
  {
315
336
  MLNOfflinePack *pack = notification.object;
316
-
337
+
317
338
  if (pack.state == MLNOfflinePackStateInvalid) {
318
339
  return; // Avoid invalid offline pack exception
319
340
  }
320
-
341
+
321
342
  if ([self _shouldSendProgressEvent:[self _getCurrentTimestamp] pack:pack]) {
322
343
  NSDictionary *metadata = [self _unarchiveMetadata:pack];
323
344
  RCTMLNEvent *event = [self _makeProgressEvent:metadata[@"name"] pack:pack];
324
345
  [self _sendEvent:RCT_MAPBOX_OFFLINE_CALLBACK_PROGRESS event:event];
325
346
  lastPackTimestamp = [self _getCurrentTimestamp];
326
347
  }
327
-
348
+
328
349
  lastPackState = pack.state;
329
350
  }
330
351
 
@@ -335,7 +356,7 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
335
356
  return; // Avoid invalid offline pack exception
336
357
  }
337
358
  NSDictionary *metadata = [self _unarchiveMetadata:pack];
338
-
359
+
339
360
  NSString *name = metadata[@"name"];
340
361
  if (name != nil) {
341
362
  NSError *error = notification.userInfo[MLNOfflinePackUserInfoKeyError];
@@ -350,7 +371,7 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
350
371
  {
351
372
  MLNOfflinePack *pack = notification.object;
352
373
  NSDictionary *metadata = [self _unarchiveMetadata:pack];
353
-
374
+
354
375
  NSString *name = metadata[@"name"];
355
376
  if (name != nil) {
356
377
  RCTMLNEvent *event = [self _makeErrorEvent:name
@@ -386,11 +407,11 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
386
407
  if ([data isKindOfClass:[NSDictionary class]]) {
387
408
  return data;
388
409
  }
389
-
410
+
390
411
  if (data == nil) {
391
412
  return @{};
392
413
  }
393
-
414
+
394
415
  return [NSJSONSerialization JSONObjectWithData:[data dataUsingEncoding:NSUTF8StringEncoding]
395
416
  options:NSJSONReadingMutableContainers
396
417
  error:nil];
@@ -406,7 +427,7 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
406
427
  if(expectedResources == 0) {
407
428
  progressPercentage = 0;
408
429
  }
409
-
430
+
410
431
  return @{
411
432
  @"state": @(pack.state),
412
433
  @"name": name,
@@ -433,15 +454,15 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
433
454
  - (NSArray<NSDictionary *> *)_convertPacksToJson:(NSArray<MLNOfflinePack *> *)packs
434
455
  {
435
456
  NSMutableArray<NSDictionary *> *jsonPacks = [NSMutableArray new];
436
-
457
+
437
458
  if (packs == nil) {
438
459
  return jsonPacks;
439
460
  }
440
-
461
+
441
462
  for (MLNOfflinePack *pack in packs) {
442
463
  [jsonPacks addObject:[self _convertPackToDict:pack]];
443
464
  }
444
-
465
+
445
466
  return jsonPacks;
446
467
  }
447
468
 
@@ -452,12 +473,12 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
452
473
  if (region == nil) {
453
474
  return nil;
454
475
  }
455
-
476
+
456
477
  NSArray *jsonBounds = @[
457
478
  @[@(region.bounds.ne.longitude), @(region.bounds.ne.latitude)],
458
479
  @[@(region.bounds.sw.longitude), @(region.bounds.sw.latitude)]
459
480
  ];
460
-
481
+
461
482
  // format metadata
462
483
  NSDictionary *metadata = [self _unarchiveMetadata:pack];
463
484
  NSData *jsonMetadata = [NSJSONSerialization dataWithJSONObject:metadata
@@ -472,19 +493,19 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
472
493
  - (MLNOfflinePack *)_getPackFromName:(NSString *)name
473
494
  {
474
495
  NSArray<MLNOfflinePack *> *packs = [[MLNOfflineStorage sharedOfflineStorage] packs];
475
-
496
+
476
497
  if (packs == nil) {
477
498
  return nil;
478
499
  }
479
-
500
+
480
501
  for (MLNOfflinePack *pack in packs) {
481
502
  NSDictionary *metadata = [self _unarchiveMetadata:pack];
482
-
503
+
483
504
  if ([name isEqualToString:metadata[@"name"]]) {
484
505
  return pack;
485
506
  }
486
507
  }
487
-
508
+
488
509
  return nil;
489
510
  }
490
511
 
@@ -501,15 +522,15 @@ RCT_EXPORT_METHOD(setProgressEventThrottle:(nonnull NSNumber *)throttleValue)
501
522
  if (lastPackState == -1) {
502
523
  return YES;
503
524
  }
504
-
525
+
505
526
  if (lastPackState != currentPack.state) {
506
527
  return YES;
507
528
  }
508
-
529
+
509
530
  if (currentTimestamp - lastPackTimestamp > eventThrottle) {
510
531
  return YES;
511
532
  }
512
-
533
+
513
534
  return NO;
514
535
  }
515
536
 
@@ -40,6 +40,12 @@ export {
40
40
  type Location,
41
41
  } from "./modules/location/locationManager";
42
42
  export { default as offlineManager } from "./modules/offline/offlineManager";
43
+ export type {
44
+ OfflineProgressStatus,
45
+ OfflinePackError,
46
+ } from "./modules/offline/offlineManager";
47
+ export type { OfflinePackStatus } from "./modules/offline/OfflinePack";
48
+ export { default as OfflinePack } from "./modules/offline/OfflinePack";
43
49
  export { default as OfflineCreatePackOptions } from "./modules/offline/OfflineCreatePackOptions";
44
50
  export { default as snapshotManager } from "./modules/snapshot/snapshotManager";
45
51
  export type { SnapshotInputOptions } from "./modules/snapshot/SnapshotOptions";
@@ -1,7 +1,6 @@
1
1
  import React, { ReactElement } from "react";
2
2
 
3
3
  import SymbolLayer from "./SymbolLayer";
4
- // @ts-ignore
5
4
  import headingIcon from "../../assets/heading.png";
6
5
  import BaseProps from "../types/BaseProps";
7
6
 
@@ -760,7 +760,7 @@ const MapView = memo(
760
760
  };
761
761
 
762
762
  const contentInsetValue = useMemo(() => {
763
- if (!props.contentInset) {
763
+ if (props.contentInset === undefined) {
764
764
  return;
765
765
  }
766
766
 
@@ -812,7 +812,7 @@ const MapView = memo(
812
812
  surfaceView,
813
813
  regionWillChangeDebounceTime,
814
814
  regionDidChangeDebounceTime,
815
- contentInsetValue,
815
+ contentInset: contentInsetValue,
816
816
  style: styles.matchParent,
817
817
  };
818
818
  }, [
@@ -825,7 +825,6 @@ const MapView = memo(
825
825
  surfaceView,
826
826
  regionWillChangeDebounceTime,
827
827
  regionDidChangeDebounceTime,
828
- contentInsetValue,
829
828
  props,
830
829
  contentInsetValue,
831
830
  ]);
@@ -4,7 +4,7 @@ import OfflineCreatePackOptions from "./OfflineCreatePackOptions";
4
4
 
5
5
  const MapLibreGLOfflineManager = NativeModules.MLNOfflineModule;
6
6
 
7
- type OfflinePackStatus = {
7
+ export type OfflinePackStatus = {
8
8
  name: string;
9
9
  state: number;
10
10
  percentage: number;
@@ -0,0 +1 @@
1
+ declare module "*.png";
package/jest-setup.ts ADDED
@@ -0,0 +1,113 @@
1
+ /* eslint-disable no-undef, import/no-extraneous-dependencies */
2
+ import "@testing-library/react-native/extend-expect";
3
+ import { NativeModules } from "react-native";
4
+
5
+ // Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
6
+ jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
7
+
8
+ function keyMirror(keys: string[]) {
9
+ const obj: Record<string, string> = {};
10
+ keys.forEach((key) => (obj[key] = key));
11
+ return obj;
12
+ }
13
+
14
+ // Mock of what the native code puts on the JS object
15
+ NativeModules.MLNModule = {
16
+ // constants
17
+ UserTrackingModes: keyMirror([
18
+ "None",
19
+ "Follow",
20
+ "FollowWithCourse",
21
+ "FollowWithHeading",
22
+ ]),
23
+ StyleURL: keyMirror(["Default"]),
24
+ EventTypes: keyMirror([
25
+ "MapClick",
26
+ "MapLongClick",
27
+ "RegionWillChange",
28
+ "RegionIsChanging",
29
+ "RegionDidChange",
30
+ "WillStartLoadingMap",
31
+ "DidFinishLoadingMap",
32
+ "DidFailLoadingMap",
33
+ "WillStartRenderingFrame",
34
+ "DidFinishRenderingFrame",
35
+ "DidFinishRenderingFrameFully",
36
+ "DidFinishLoadingStyle",
37
+ "SetCameraComplete",
38
+ ]),
39
+ CameraModes: keyMirror(["Flight", "Ease", "None"]),
40
+ StyleSource: keyMirror(["DefaultSourceID"]),
41
+ InterpolationMode: keyMirror([
42
+ "Exponential",
43
+ "Categorical",
44
+ "Interval",
45
+ "Identity",
46
+ ]),
47
+ LineJoin: keyMirror(["Bevel", "Round", "Miter"]),
48
+ LineCap: keyMirror(["Butt", "Round", "Square"]),
49
+ LineTranslateAnchor: keyMirror(["Map", "Viewport"]),
50
+ CirclePitchScale: keyMirror(["Map", "Viewport"]),
51
+ CircleTranslateAnchor: keyMirror(["Map", "Viewport"]),
52
+ FillExtrusionTranslateAnchor: keyMirror(["Map", "Viewport"]),
53
+ FillTranslateAnchor: keyMirror(["Map", "Viewport"]),
54
+ IconRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
55
+ IconTextFit: keyMirror(["None", "Width", "Height", "Both"]),
56
+ IconTranslateAnchor: keyMirror(["Map", "Viewport"]),
57
+ SymbolPlacement: keyMirror(["Line", "Point"]),
58
+ TextAnchor: keyMirror([
59
+ "Center",
60
+ "Left",
61
+ "Right",
62
+ "Top",
63
+ "Bottom",
64
+ "TopLeft",
65
+ "TopRight",
66
+ "BottomLeft",
67
+ "BottomRight",
68
+ ]),
69
+ TextJustify: keyMirror(["Center", "Left", "Right"]),
70
+ TextPitchAlignment: keyMirror(["Auto", "Map", "Viewport"]),
71
+ TextRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
72
+ TextTransform: keyMirror(["None", "Lowercase", "Uppercase"]),
73
+ TextTranslateAnchor: keyMirror(["Map", "Viewport"]),
74
+ LightAnchor: keyMirror(["Map", "Viewport"]),
75
+ OfflinePackDownloadState: keyMirror(["Inactive", "Active", "Complete"]),
76
+ OfflineCallbackName: keyMirror(["Progress", "Error"]),
77
+
78
+ // methods
79
+ setAccessToken: jest.fn(),
80
+ getAccessToken: () => Promise.resolve("test-token"),
81
+ setConnected: jest.fn(),
82
+ };
83
+
84
+ NativeModules.MLNOfflineModule = {
85
+ createPack: (packOptions: any) => {
86
+ return Promise.resolve({
87
+ bounds: packOptions.bounds,
88
+ metadata: JSON.stringify({ name: packOptions.name }),
89
+ });
90
+ },
91
+ getPacks: () => Promise.resolve([]),
92
+ deletePack: () => Promise.resolve(),
93
+ getPackStatus: () => Promise.resolve({}),
94
+ pausePackDownload: () => Promise.resolve(),
95
+ resumePackDownload: () => Promise.resolve(),
96
+ setPackObserver: () => Promise.resolve(),
97
+ setTileCountLimit: jest.fn(),
98
+ setProgressEventThrottle: jest.fn(),
99
+ };
100
+
101
+ NativeModules.MLNSnapshotModule = {
102
+ takeSnap: () => {
103
+ return Promise.resolve("file://test.png");
104
+ },
105
+ };
106
+
107
+ NativeModules.MLNLocationModule = {
108
+ getLastKnownLocation: jest.fn(),
109
+ setMinDisplacement: jest.fn(),
110
+ start: jest.fn(),
111
+ stop: jest.fn(),
112
+ pause: jest.fn(),
113
+ };
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ preset: "@testing-library/react-native",
3
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
4
+ setupFilesAfterEnv: ["./jest-setup.ts"],
5
+ setupFiles: ["./__tests__/__mocks__/react-native.mock.js"],
6
+ modulePathIgnorePatterns: ["__tests__/__mocks__", "fixtures"],
7
+ collectCoverageFrom: ["javascript/**/*.{ts,tsx,js,jsx}"],
8
+ };