From 58abdb0a854e1e17e5dbb15e950e790579ee1716 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 10 Dec 2024 12:58:56 +0100 Subject: [PATCH] fix: export custom header methods (#552) Fixes #551 --- __tests__/{interface.test.js => exports.ts} | 69 +++++++++++---------- jest-setup.ts | 6 +- src/MLRNModule.ts | 9 +++ 3 files changed, 51 insertions(+), 33 deletions(-) rename __tests__/{interface.test.js => exports.ts} (56%) diff --git a/__tests__/interface.test.js b/__tests__/exports.ts similarity index 56% rename from __tests__/interface.test.js rename to __tests__/exports.ts index c2e7b0682..9207fed77 100644 --- a/__tests__/interface.test.js +++ b/__tests__/exports.ts @@ -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", @@ -44,37 +43,43 @@ 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", @@ -82,14 +87,14 @@ describe("Public Interface", () => { "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()); }); }); diff --git a/jest-setup.ts b/jest-setup.ts index 913bdecdb..ee8540f41 100644 --- a/jest-setup.ts +++ b/jest-setup.ts @@ -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(), }; diff --git a/src/MLRNModule.ts b/src/MLRNModule.ts index ba44cff1a..c628daa7e 100644 --- a/src/MLRNModule.ts +++ b/src/MLRNModule.ts @@ -29,6 +29,10 @@ interface IMLRNModule { setAccessToken(accessToken: string | null): Promise; getAccessToken(): Promise; + + addCustomHeader(headerName: string, headerValue: string): void; + removeCustomHeader(headerName: string): void; + setConnected(connected: boolean): void; } @@ -40,7 +44,12 @@ export const { OfflinePackDownloadState, LineJoin, StyleSource, + setAccessToken, getAccessToken, + + addCustomHeader, + removeCustomHeader, + setConnected, } = MLRNModule;