From e5360eb0e69976bf765f8fd3d95413203bb3bc42 Mon Sep 17 00:00:00 2001 From: Jessicuta Date: Mon, 30 Mar 2026 23:46:15 -0400 Subject: [PATCH] remove the demo location --- __tests__/BuildingInfoPopup.test.tsx | 55 +++++++++++----------------- components/BuildingInfoPopup.tsx | 23 ++++-------- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/__tests__/BuildingInfoPopup.test.tsx b/__tests__/BuildingInfoPopup.test.tsx index 69b5bb1..af50dd6 100644 --- a/__tests__/BuildingInfoPopup.test.tsx +++ b/__tests__/BuildingInfoPopup.test.tsx @@ -9,9 +9,7 @@ jest.mock("../components/AccessibilityIcons", () => { const { Text } = require("react-native"); return { BuildingIcons: ({ icons, size }: any) => ( - - {JSON.stringify({ icons, size })} - + {JSON.stringify({ icons, size })} ), }; }); @@ -70,7 +68,7 @@ describe("BuildingInfoPopup", () => { it("returns null when building is null", () => { const { queryByText } = render( - + , ); expect(queryByText("Set as start")).toBeNull(); }); @@ -116,7 +114,7 @@ describe("BuildingInfoPopup", () => { it("does not render BuildingIcons when icons is undefined", () => { render( - + , ); expect(screen.queryByTestId("building-icons")).toBeNull(); }); @@ -136,14 +134,16 @@ describe("BuildingInfoPopup", () => { }); it("renders only Departments tab when building has no services", () => { - render(); + render( + , + ); expect(screen.getByText("Departments")).toBeTruthy(); expect(screen.queryByText("Services")).toBeNull(); }); it("renders no tabs when building has neither departments nor services", () => { render( - + , ); expect(screen.queryByText("Departments")).toBeNull(); expect(screen.queryByText("Services")).toBeNull(); @@ -219,7 +219,7 @@ describe("BuildingInfoPopup", () => { it("resets the active tab when building prop changes", () => { const { rerender } = render( - + , ); // open departments @@ -228,7 +228,7 @@ describe("BuildingInfoPopup", () => { // switch to a different building rerender( - + , ); // the tab content should be gone - activeTab reset to null @@ -243,7 +243,7 @@ describe("BuildingInfoPopup", () => { building={fullBuilding} onClose={onClose} onSetAsStart={onSetAsStart} - /> + />, ); fireEvent.press(screen.getByText("Set as start")); expect(onSetAsStart).toHaveBeenCalledTimes(1); @@ -257,7 +257,7 @@ describe("BuildingInfoPopup", () => { building={fullBuilding} onClose={onClose} onSetAsDestination={onSetAsDestination} - /> + />, ); fireEvent.press(screen.getByText("Set as destination")); expect(onSetAsDestination).toHaveBeenCalledTimes(1); @@ -266,30 +266,17 @@ describe("BuildingInfoPopup", () => { // --- Navigation button: Set as my location (demo) --- - it("calls onSetAsMyLocation when Set as my location button is pressed", () => { + it("does not render Set as my location button even when onSetAsMyLocation is provided", () => { const onSetAsMyLocation = jest.fn(); render( + />, ); - fireEvent.press(screen.getByText("Set as my location (demo)")); - expect(onSetAsMyLocation).toHaveBeenCalledTimes(1); - expect(onSetAsMyLocation).toHaveBeenCalledWith(fullBuilding); - }); - it("renders Set as my location button only when onSetAsMyLocation is provided", () => { - const onSetAsMyLocation = jest.fn(); - render( - - ); - expect(screen.getByText("Set as my location (demo)")).toBeTruthy(); + expect(screen.queryByText("Set as my location (demo)")).toBeNull(); }); it("does not render Set as my location button when onSetAsMyLocation is not provided", () => { @@ -300,20 +287,20 @@ describe("BuildingInfoPopup", () => { it("does not call callbacks when they are not provided", () => { // This test ensures the component doesn't crash when optional callbacks are undefined render(); - + // Should not crash when pressed fireEvent.press(screen.getByText("Set as start")); fireEvent.press(screen.getByText("Set as destination")); - + // No errors means success expect(screen.getByText("Hall Building")).toBeTruthy(); }); - it("renders all three navigation buttons when all callbacks are provided", () => { + it("renders start and destination navigation buttons when callbacks are provided", () => { const onSetAsStart = jest.fn(); const onSetAsDestination = jest.fn(); const onSetAsMyLocation = jest.fn(); - + render( { onSetAsStart={onSetAsStart} onSetAsDestination={onSetAsDestination} onSetAsMyLocation={onSetAsMyLocation} - /> + />, ); - + expect(screen.getByText("Set as start")).toBeTruthy(); expect(screen.getByText("Set as destination")).toBeTruthy(); - expect(screen.getByText("Set as my location (demo)")).toBeTruthy(); + expect(screen.queryByText("Set as my location (demo)")).toBeNull(); }); it("shows the indoor button when indoor access is available", () => { diff --git a/components/BuildingInfoPopup.tsx b/components/BuildingInfoPopup.tsx index ae13365..114f313 100644 --- a/components/BuildingInfoPopup.tsx +++ b/components/BuildingInfoPopup.tsx @@ -52,7 +52,11 @@ export const BuildingInfoPopup = ({ } return ( - + @@ -77,7 +81,9 @@ export const BuildingInfoPopup = ({ Campus: - {building.campusName.toUpperCase()} + + {building.campusName.toUpperCase()} + {building.icons && building.icons.length > 0 && ( @@ -181,20 +187,7 @@ export const BuildingInfoPopup = ({ Open indoor map )} - - {onSetAsMyLocation && ( - onSetAsMyLocation(building)} - accessibilityRole="button" - accessibilityLabel={`Use ${building.displayName} as my location (demo)`} - > - Set as my location (demo) - - )} ); }; -