Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drop MapLibreGL naming and export default #567

Draft
wants to merge 17 commits into
base: beta
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ diverged, it has become necessary to separate the projects into specific wrapper

### Modules

- [OfflineManager](/docs/modules/offlineManager.md)
- [SnapshotManager](/docs/modules/snapshotManager.md)
- [OfflineManager](/docs/modules/OfflineManager.md)
- [SnapshotManager](/docs/modules/SnapshotManager.md)

### Misc

- [MapLibreGL](/docs/guides/MapLibreGL.md)
- [MLRNModule](/docs/guides/MLRNModule)
- [Custom HTTP Headers](/docs/guides/CustomHTTPHeaders.md)
- [Logger](/docs/guides/Logger.md)

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/BackgroundLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import BackgroundLayer from "../../src/components/BackgroundLayer";
import { BackgroundLayer } from "../../src";

describe("BackgroundLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Callout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render } from "@testing-library/react-native";
import React from "react";
import { View } from "react-native";

import Callout from "../../src/components/Callout";
import { Callout } from "../../src";

describe("Callout", () => {
test("renders with custom title", () => {
Expand Down
9 changes: 5 additions & 4 deletions __tests__/components/Camera.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { render } from "@testing-library/react-native";
import React from "react";
import { createRef } from "react";

import Camera, {
import {
Camera,
type CameraBounds,
type CameraProps,
type CameraRef,
Expand All @@ -13,15 +14,15 @@ import Camera, {
} from "../../src/components/Camera";
import { type NativeRef } from "../../src/hooks/useNativeRef";

const mockCameraNativeRef = React.createRef<NativeRef<NativeCameraProps>>();
const mockCameraNativeRef = createRef<NativeRef<NativeCameraProps>>();
jest.mock("../../src/hooks/useNativeRef", () => ({
useNativeRef: () => {
return mockCameraNativeRef;
},
}));

function renderCamera(props: CameraProps = {}) {
const cameraRef = React.createRef<CameraRef>();
const cameraRef = createRef<CameraRef>();

const result = render(<Camera {...props} ref={cameraRef} />);

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/CircleLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import CircleLayer from "../../src/components/CircleLayer";
import { CircleLayer } from "../../src";

describe("CircleLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/HeatmapLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import HeatmapLayer from "../../src/components/HeatmapLayer";
import { HeatmapLayer } from "../../src";

describe("HeatmapLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Light.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import Light from "../../src/components/Light";
import { Light } from "../../src";

describe("Light", () => {
test("renders correctly", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/MapView.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import * as React from "react";

import MapView from "../../src/components/MapView";
import { MapView } from "../../src";

describe("MapView", () => {
test("renders with testID", () => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/components/SymbolLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { render } from "@testing-library/react-native";
import React from "react";

import SymbolLayer, {
import {
SymbolLayer,
NATIVE_MODULE_NAME,
} from "../../src/components/SymbolLayer";

Expand Down
48 changes: 25 additions & 23 deletions __tests__/components/UserLocation.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { render, fireEvent, waitFor } from "@testing-library/react-native";
import React from "react";
import React, { createRef } from "react";

import CircleLayer from "../../src/components/CircleLayer";
import ShapeSource from "../../src/components/ShapeSource";
import UserLocation from "../../src/components/UserLocation";
import locationManager from "../../src/modules/location/locationManager";
import {
CircleLayer,
ShapeSource,
UserLocation,
LocationManager,
} from "../../src";

const position = {
coords: {
Expand All @@ -20,7 +22,7 @@ const position = {
};

function renderUserLocation(props = {}) {
const userLocationRef = React.createRef();
const userLocationRef = createRef();
const { rerender, unmount } = render(
<UserLocation {...props} ref={userLocationRef} />,
);
Expand All @@ -34,14 +36,14 @@ function renderUserLocation(props = {}) {

describe("UserLocation", () => {
describe("render", () => {
jest.spyOn(locationManager, "start").mockImplementation(jest.fn());
jest.spyOn(LocationManager, "start").mockImplementation(jest.fn());
jest
.spyOn(locationManager, "getLastKnownLocation")
.spyOn(LocationManager, "getLastKnownLocation")
.mockImplementation(() => position);

jest.spyOn(locationManager, "addListener");
jest.spyOn(LocationManager, "addListener");

jest.spyOn(locationManager, "removeListener");
jest.spyOn(LocationManager, "removeListener");

beforeEach(() => {
jest.clearAllMocks();
Expand Down Expand Up @@ -102,7 +104,7 @@ describe("UserLocation", () => {

render(<UserLocation onUpdate={onUpdateCallback} />);

locationManager.onUpdate({
LocationManager.onUpdate({
coords: {
accuracy: 9.977999687194824,
altitude: 44.64373779296875,
Expand Down Expand Up @@ -136,21 +138,21 @@ describe("UserLocation", () => {
test("correctly unmounts", async () => {
const { unmount } = renderUserLocation();

expect(locationManager.addListener).toHaveBeenCalledTimes(1);
expect(locationManager.removeListener).not.toHaveBeenCalled();
expect(LocationManager.addListener).toHaveBeenCalledTimes(1);
expect(LocationManager.removeListener).not.toHaveBeenCalled();

unmount();

expect(locationManager.removeListener).toHaveBeenCalledTimes(1);
expect(LocationManager.removeListener).toHaveBeenCalledTimes(1);
});
});

describe("methods", () => {
beforeEach(() => {
jest.spyOn(locationManager, "start").mockImplementation(jest.fn());
jest.spyOn(locationManager, "stop").mockImplementation(jest.fn());
jest.spyOn(LocationManager, "start").mockImplementation(jest.fn());
jest.spyOn(LocationManager, "stop").mockImplementation(jest.fn());
jest
.spyOn(locationManager, "getLastKnownLocation")
.spyOn(LocationManager, "getLastKnownLocation")
.mockImplementation(() => position);
});

Expand All @@ -160,7 +162,7 @@ describe("UserLocation", () => {

test("initial state is as expected", () => {
renderUserLocation();
expect(locationManager.start).toHaveBeenCalledTimes(1);
expect(LocationManager.start).toHaveBeenCalledTimes(1);
});

// TODO: replace object { running: boolean } argument with simple boolean
Expand All @@ -171,8 +173,8 @@ describe("UserLocation", () => {

await userLocationRef.current.setLocationManager({ running: true });

expect(locationManager.start).toHaveBeenCalledTimes(1);
expect(locationManager.getLastKnownLocation).toHaveBeenCalledTimes(1);
expect(LocationManager.start).toHaveBeenCalledTimes(1);
expect(LocationManager.getLastKnownLocation).toHaveBeenCalledTimes(1);
expect(onUpdate).toHaveBeenCalledWith({
coords: {
accuracy: 9.977999687194824,
Expand All @@ -186,7 +188,7 @@ describe("UserLocation", () => {
timestamp: 1573730357879,
});

expect(locationManager.stop).not.toHaveBeenCalled();
expect(LocationManager.stop).not.toHaveBeenCalled();
});

test('called with "running" false', async () => {
Expand All @@ -198,9 +200,9 @@ describe("UserLocation", () => {
await userLocationRef.current.setLocationManager({ running: false });

// only once from start
expect(locationManager.start).toHaveBeenCalledTimes(1);
expect(LocationManager.start).toHaveBeenCalledTimes(1);
// stop should not be called
expect(locationManager.stop).not.toHaveBeenCalled();
expect(LocationManager.stop).not.toHaveBeenCalled();
});
});

Expand Down
10 changes: 5 additions & 5 deletions __tests__/exports.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import MapLibreGL from "../src";
import * as MapLibreRN from "../src";

describe("Package Exports", () => {
it("should contain all expected components and utils", () => {
const actualKeys = Object.keys(MapLibreGL);
const actualKeys = Object.keys(MapLibreRN);

const expectedKeys = [
// Components
Expand All @@ -16,11 +16,11 @@ describe("Package Exports", () => {
"UserLocation",

// modules
"offlineManager",
"OfflineManager",
"OfflineCreatePackOptions",
"OfflinePack",
"snapshotManager",
"locationManager",
"SnapshotManager",
"LocationManager",

// layers
"FillLayer",
Expand Down
Loading
Loading