Skip to content

Commit

Permalink
fix: export custom header methods (#552)
Browse files Browse the repository at this point in the history
Fixes #551
  • Loading branch information
KiwiKilian authored Dec 10, 2024
1 parent 1469f3f commit 58abdb0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
69 changes: 37 additions & 32 deletions __tests__/interface.test.js → __tests__/exports.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import MapLibreGL from "../src";

// Assert that all required MapLibre modules are accessible and exported
describe("Public Interface", () => {
describe("Package Exports", () => {
it("should contain all expected components and utils", () => {
const actualKeys = Object.keys(MapLibreGL);

const expectedKeys = [
// components
// Components
"MapView",
// 'StyleSheet',
"Light",
"PointAnnotation",
"MarkerView",
Expand Down Expand Up @@ -44,52 +43,58 @@ describe("Public Interface", () => {
"UserTrackingMode",
"UserLocationRenderMode",
"StyleURL",
"EventTypes",
// "EventTypes",
"CameraModes",
"StyleSource",
"InterpolationMode",
// "InterpolationMode",
"LineJoin",
"LineCap",
"LineTranslateAnchor",
"CirclePitchScale",
"CircleTranslateAnchor",
// "LineCap",
// "LineTranslateAnchor",
// "CirclePitchScale",
// "CircleTranslateAnchor",
// 'CirclePitchAlignment',
"FillExtrusionTranslateAnchor",
"FillTranslateAnchor",
"IconRotationAlignment",
"IconTextFit",
// "FillExtrusionTranslateAnchor",
// "FillTranslateAnchor",
// "IconRotationAlignment",
// "IconTextFit",
// 'IconAnchor',
"IconTranslateAnchor",
// "IconTranslateAnchor",
// 'IconPitchAlignment',
"SymbolPlacement",
"TextAnchor",
"TextJustify",
"TextPitchAlignment",
"TextRotationAlignment",
"TextTransform",
"TextTranslateAnchor",
"LightAnchor",
// "SymbolPlacement",
// "TextAnchor",
// "TextJustify",
// "TextPitchAlignment",
// "TextRotationAlignment",
// "TextTransform",
// "TextTranslateAnchor",
// "LightAnchor",

"OfflinePackDownloadState",
"OfflineCallbackName",
// "OfflineCallbackName",

// Methods

// methods
"setAccessToken",
"getAccessToken",

"addCustomHeader",
"removeCustomHeader",

"setConnected",
"requestAndroidLocationPermissions",

// animated
"Animated",

// helpers
"AnimatedPoint",
"AnimatedCoordinatesArray",
"AnimatedShape",
"AnimatedExtractCoordinateFromArray",
"AnimatedRouteCoordinatesArray",
// "AnimatedPoint",
// "AnimatedCoordinatesArray",
// "AnimatedShape",
// "AnimatedExtractCoordinateFromArray",
// "AnimatedRouteCoordinatesArray",
"Logger",
"Style",
];
actualKeys.forEach((key) => expect(expectedKeys).toContain(key));

expect(actualKeys.sort()).toEqual(expectedKeys.sort());
});
});
6 changes: 5 additions & 1 deletion jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ NativeModules.MLRNModule = {
OfflinePackDownloadState: keyMirror(["Inactive", "Active", "Complete"]),
OfflineCallbackName: keyMirror(["Progress", "Error"]),

// methods
// Methods
setAccessToken: jest.fn(),
getAccessToken: () => Promise.resolve("test-token"),

addCustomHeader: jest.fn(),
removeCustomHeader: jest.fn(),

setConnected: jest.fn(),
};

Expand Down
9 changes: 9 additions & 0 deletions src/MLRNModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ interface IMLRNModule {

setAccessToken(accessToken: string | null): Promise<string | null>;
getAccessToken(): Promise<string>;

addCustomHeader(headerName: string, headerValue: string): void;
removeCustomHeader(headerName: string): void;

setConnected(connected: boolean): void;
}

Expand All @@ -40,7 +44,12 @@ export const {
OfflinePackDownloadState,
LineJoin,
StyleSource,

setAccessToken,
getAccessToken,

addCustomHeader,
removeCustomHeader,

setConnected,
} = MLRNModule;

0 comments on commit 58abdb0

Please sign in to comment.