Skip to content

Commit

Permalink
Merge pull request #64 from vietmap-company/runLintFormat
Browse files Browse the repository at this point in the history
Run lint format
  • Loading branch information
thanhdt-vietmap authored Feb 21, 2024
2 parents 7210846 + f4fb513 commit 2aeda08
Show file tree
Hide file tree
Showing 76 changed files with 285 additions and 228 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ coverage

# Config plugin
/plugin/build
/javascript/vietmap_api_key.ts
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_A React Native library for building maps with
the [Vietmap GL Native SDK for iOS & Android](https://bit.ly/vietmap-api)_.


https://www.jawg.io/docs/integration/react-native/add-marker/

<br>

Expand Down Expand Up @@ -64,3 +64,4 @@ set up your local dev environment.
## Community

Join the #maplibre-native Slack channel at OSMUS: get an invite at https://slack.openstreetmap.us/
https://www.jawg.io/docs/integration/react-native/
4 changes: 2 additions & 2 deletions __tests__/components/BackgroundLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BackgroundLayer from '../../javascript/components/BackgroundLayer';

import React from 'react';
import {render} from '@testing-library/react-native';

import BackgroundLayer from '../../javascript/components/BackgroundLayer';

describe('BackgroundLayer', () => {
test('renders correctly with default props', () => {
const {queryByTestId} = render(
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Callout.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Callout from '../../javascript/components/Callout';

import React from 'react';
import {render} from '@testing-library/react-native';
import {Text, View} from 'react-native';

import Callout from '../../javascript/components/Callout';

describe('Callout', () => {
test('renders with custom title', () => {
const testTitle = 'test title';
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Camera.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Camera from '../../javascript/components/Camera';

import React from 'react';
import {render} from '@testing-library/react-native';

import Camera from '../../javascript/components/Camera';

const cameraWithoutFollowDefault = {
...Camera.defaultProps,
animationDuration: 2000,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/CircleLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CircleLayer from '../../javascript/components/CircleLayer';

import React from 'react';
import {render} from '@testing-library/react-native';

import CircleLayer from '../../javascript/components/CircleLayer';

describe('CircleLayer', () => {
test('renders correctly with default props', () => {
const {queryByTestId} = render(<CircleLayer id="requiredCircleLayerID" />);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/HeatmapLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import HeatmapLayer from '../../javascript/components/HeatmapLayer';

import React from 'react';
import {render} from '@testing-library/react-native';

import HeatmapLayer from '../../javascript/components/HeatmapLayer';

describe('HeatmapLayer', () => {
test('renders correctly with default props', () => {
const {UNSAFE_getByType} = render(
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Light.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Light from '../../javascript/components/Light';

import React from 'react';
import {render} from '@testing-library/react-native';

import Light from '../../javascript/components/Light';

describe('Light', () => {
test('renders correctly', () => {
const {queryByTestId} = render(<Light />);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/MapView.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import MapView from '../../javascript/components/MapView';

import * as React from 'react';
import {render} from '@testing-library/react-native';

import MapView from '../../javascript/components/MapView';

describe('MapView', () => {
test('renders with testID', () => {
const expectedTestId = 'im used for identification in tests';
Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/Style.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import React from 'react';
import {render} from '@testing-library/react-native';

import VectorSource from '../../javascript/components/VectorSource';
import RasterSource from '../../javascript/components/RasterSource';
import ImageSource from '../../javascript/components/ImageSource';
Expand All @@ -12,9 +15,6 @@ import FillLayer from '../../javascript/components/FillLayer';
import FillExtrusionLayer from '../../javascript/components/FillExtrusionLayer';
import BackgroundLayer from '../../javascript/components/BackgroundLayer';

import React from 'react';
import {render} from '@testing-library/react-native';

describe('Style', () => {
test('renders vectory source correctly', () => {
const vectorSource = {
Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/SymbolLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import {render} from '@testing-library/react-native';

import SymbolLayer, {
NATIVE_MODULE_NAME,
} from '../../javascript/components/SymbolLayer';

import React from 'react';
import {render} from '@testing-library/react-native';

describe('SymbolLayer', () => {
test('renders correctly with default props', () => {
const {UNSAFE_getByType} = render(
Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/UserLocation.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import {render, fireEvent} from '@testing-library/react-native';

import UserLocation from '../../javascript/components/UserLocation';
import ShapeSource from '../../javascript/components/ShapeSource';
import CircleLayer from '../../javascript/components/CircleLayer';
import locationManager from '../../javascript/modules/location/locationManager';

import React from 'react';
import {render, fireEvent} from '@testing-library/react-native';

const position = {
coords: {
accuracy: 9.977999687194824,
Expand Down
44 changes: 22 additions & 22 deletions __tests__/modules/location/locationManager.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NativeModules} from 'react-native';

import LocationManager, {
LocationModuleEventEmitter,
} from '../../../javascript/modules/location/locationManager';

import {NativeModules} from 'react-native';

const VietmapGL = NativeModules.MGLModule;
const MapLibreGLLocationManager = NativeModules.MGLLocationModule;
const VietmapGLLocationManager = NativeModules.MGLLocationModule;

const location = {
coords: {
Expand Down Expand Up @@ -37,15 +37,15 @@ describe('LocationManager', () => {
describe('#getLastKnownLocation', () => {
test('gets last known location from native locationManager if non available', async () => {
jest
.spyOn(MapLibreGLLocationManager, 'getLastKnownLocation')
.spyOn(VietmapGLLocationManager, 'getLastKnownLocation')
.mockImplementation(() => location);

const lastKnownLocation = await locationManager.getLastKnownLocation();

expect(lastKnownLocation).toStrictEqual(location);
expect(locationManager._lastKnownLocation).toStrictEqual(location);
expect(
MapLibreGLLocationManager.getLastKnownLocation,
VietmapGLLocationManager.getLastKnownLocation,
).toHaveBeenCalledTimes(1);

locationManager._lastKnownLocation = null;
Expand All @@ -59,7 +59,7 @@ describe('LocationManager', () => {
expect(locationManager._lastKnownLocation).toStrictEqual(location);

expect(
MapLibreGLLocationManager.getLastKnownLocation,
VietmapGLLocationManager.getLastKnownLocation,
).not.toHaveBeenCalled();

// reset
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('LocationManager', () => {
});

describe('#removeListener', () => {
MapLibreGLLocationManager.stop = jest.fn();
VietmapGLLocationManager.stop = jest.fn();

test('removes selected listener', () => {
// just two different functions
Expand All @@ -109,22 +109,22 @@ describe('LocationManager', () => {

locationManager.addListener(listenerA);
expect(locationManager._listeners).toStrictEqual([listenerA]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(VietmapGLLocationManager.stop).not.toHaveBeenCalled();

locationManager.addListener(listenerB);
expect(locationManager._listeners).toStrictEqual([
listenerA,
listenerB,
]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(VietmapGLLocationManager.stop).not.toHaveBeenCalled();

locationManager.removeListener(listenerB);
expect(locationManager._listeners).toStrictEqual([listenerA]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(VietmapGLLocationManager.stop).not.toHaveBeenCalled();

locationManager.removeListener(listenerA);
expect(locationManager._listeners).toStrictEqual([]);
expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(VietmapGLLocationManager.stop).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -148,7 +148,7 @@ describe('LocationManager', () => {
});

describe('#start', () => {
jest.spyOn(MapLibreGLLocationManager, 'start');
jest.spyOn(VietmapGLLocationManager, 'start');
jest.spyOn(LocationModuleEventEmitter, 'addListener');

afterEach(() => {
Expand All @@ -162,7 +162,7 @@ describe('LocationManager', () => {

locationManager.start();

expect(MapLibreGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(VietmapGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(LocationModuleEventEmitter.addListener).toHaveBeenCalledWith(
VietmapGL.LocationCallbackName.Update,
locationManager.onUpdate,
Expand All @@ -174,8 +174,8 @@ describe('LocationManager', () => {
test('passes "displacement"', () => {
locationManager.start(5); // displacement 5meters

expect(MapLibreGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(MapLibreGLLocationManager.start).toHaveBeenCalledWith(5);
expect(VietmapGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(VietmapGLLocationManager.start).toHaveBeenCalledWith(5);
});

test('does not start when already listening', () => {
Expand All @@ -186,7 +186,7 @@ describe('LocationManager', () => {

locationManager.start();

expect(MapLibreGLLocationManager.start).not.toHaveBeenCalled();
expect(VietmapGLLocationManager.start).not.toHaveBeenCalled();
expect(LocationModuleEventEmitter.addListener).not.toHaveBeenCalled();
});
});
Expand All @@ -197,14 +197,14 @@ describe('LocationManager', () => {
locationManager._isListening = true;

// native location manager has no #stop exposed in tests?
MapLibreGLLocationManager.stop = jest.fn();
VietmapGLLocationManager.stop = jest.fn();
VietmapGL.LocationCallbackName = {Update: 'MapboxUserLocationUpdate'};

expect(locationManager._isListening).toStrictEqual(true);

locationManager.stop();

expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(VietmapGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(locationManager.subscription.remove).toHaveBeenCalled();

expect(locationManager._isListening).toStrictEqual(false);
Expand All @@ -215,24 +215,24 @@ describe('LocationManager', () => {
locationManager._isListening = false;

// native location manager has no #stop exposed in tests?
MapLibreGLLocationManager.stop = jest.fn();
VietmapGLLocationManager.stop = jest.fn();
VietmapGL.LocationCallbackName = {Update: 'MapboxUserLocationUpdate'};

expect(locationManager._isListening).toStrictEqual(false);

locationManager.stop();

expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(VietmapGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(locationManager.subscription.remove).not.toHaveBeenCalled();
});
});

describe('#setMinDisplacement', () => {
test('calls native "setMinDisplacement"', () => {
MapLibreGLLocationManager.setMinDisplacement = jest.fn();
VietmapGLLocationManager.setMinDisplacement = jest.fn();
locationManager.setMinDisplacement(5);
expect(
MapLibreGLLocationManager.setMinDisplacement,
VietmapGLLocationManager.setMinDisplacement,
).toHaveBeenCalledWith(5);
});
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/modules/offline/OfflineCreatePackOptions.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import OfflineCreatePackOptions from '../../../javascript/modules/offline/OfflineCreatePackOptions';

import {featureCollection, point} from '@turf/helpers';

import OfflineCreatePackOptions from '../../../javascript/modules/offline/OfflineCreatePackOptions';

describe('OfflineCreatePackOptions', () => {
const options = {
name: 'test',
Expand Down
4 changes: 2 additions & 2 deletions __tests__/modules/offline/OfflinePack.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import OfflinePack from '../../../javascript/modules/offline/OfflinePack';

import {NativeModules} from 'react-native';

import OfflinePack from '../../../javascript/modules/offline/OfflinePack';

describe('OfflinePack', () => {
const fakeNativePack = {
bounds: [
Expand Down
4 changes: 2 additions & 2 deletions __tests__/modules/offline/offlineManager.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {NativeModules, Platform} from 'react-native';

import VietmapGL from '../../../javascript';
import {OfflineModuleEventEmitter} from '../../../javascript/modules/offline/offlineManager';

import {NativeModules, Platform} from 'react-native';

describe('offlineManager', () => {
const packOptions = {
name: 'test',
Expand Down
4 changes: 2 additions & 2 deletions __tests__/modules/snapshot/SnapshotOptions.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NativeModules} from 'react-native';

import SnapshotOptions from '../../../javascript/modules/snapshot/SnapshotOptions';
import {
makePoint,
makeFeatureCollection,
} from '../../../javascript/utils/geoUtils';

import {NativeModules} from 'react-native';

describe('SnapshotOptions', () => {
it('should throw error if no centerCoordinate or bounds are provided', () => {
expect(() => new SnapshotOptions()).toThrow();
Expand Down
8 changes: 4 additions & 4 deletions __tests__/utils/animated/AnimatedCoordinatesArray.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable fp/no-mutating-methods */

import ShapeSource from '../../../javascript/components/ShapeSource';
import AnimatedShape from '../../../javascript/utils/animated/AnimatedShape';
import AnimatedCoordinatesArray from '../../../javascript/utils/animated/AnimatedCoordinatesArray';

import FakeTimers from '@sinonjs/fake-timers';
import {Animated, Easing} from 'react-native';
import TestRenderer from 'react-test-renderer';
import React from 'react';

import AnimatedCoordinatesArray from '../../../javascript/utils/animated/AnimatedCoordinatesArray';
import AnimatedShape from '../../../javascript/utils/animated/AnimatedShape';
import ShapeSource from '../../../javascript/components/ShapeSource';

let clock = null;
let oldNodeEnv = null;

Expand Down
9 changes: 4 additions & 5 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ Here is an example minimal App.js
```js
import React, {Component} from 'react';
import {StyleSheet, View} from 'react-native';
import MapLibreGL from '@maplibre/maplibre-react-native';
import Vietmap from '@maplibre/maplibre-react-native';

// Will be null for most users (only Mapbox authenticates this way).
// Will be null for most users (only Vietmap authenticates this way).
// Required on Android. See Android installation notes.
MapLibreGL.setAccessToken(null);

Expand All @@ -80,10 +80,9 @@ export default class App extends Component {
render() {
return (
<View style={styles.page}>
<MapLibreGL.MapView
<Vietmap.MapView
style={styles.map}
logoEnabled={false}
styleURL="https://demotiles.maplibre.org/style.json"
styleURL="https://maps.vietmap.vn/api/maps/light/styles.json?apikey=YOUR_API_KEY_HERE"
/>
</View>
);
Expand Down
Loading

0 comments on commit 2aeda08

Please sign in to comment.