diff --git a/__tests__/__snapshots__/building-highlights.test.js.snap b/__tests__/__snapshots__/building-highlights.test.js.snap new file mode 100644 index 00000000..a48cc3bc --- /dev/null +++ b/__tests__/__snapshots__/building-highlights.test.js.snap @@ -0,0 +1,6202 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BuildingHighlights component should match snapshot 1`] = ` + + + + + + H + + + + + + + + CB + + + + + + + + GM + + + + + + + + LB + + + + + + + + GN + + + + + + + + EV + + + + + + + + MB + + + + + + + + FG + + + + + + + + GS + + + + + + + + LD + + + + + + + + TD + + + + + + + + VA + + + + + + + + SB + + + + + + + + Q + + + + + + + + P + + + + + + + + T + + + + + + + + RR + + + + + + + + R + + + + + + + + FA + + + + + + + + X + + + + + + + + Z + + + + + + + + V + + + + + + + + S + + + + + + + + MI + + + + + + + + MU + + + + + + + + D + + + + + + + + B + + + + + + + + LS + + + + + + + + SP + + + + + + + + TA + + + + + + + + CJ + + + + + + + + CC + + + + + + + + AD + + + + + + + + PS + + + + + + + + RA + + + + + + + + PC + + + + + + + + GE + + + + + + + + VL + + + + + + + + BH + + + + + + + + BB + + + + + + + + FC + + + + + + + + RF + + + + + + + + PY + + + + + + + + HA + + + + + + + + HC + + + + + + + + SI + + + + + + + VE + + + + + + + + PR + + + + + + + + CI + + + + + + + + M + + + + + + + + PT + + + + + + + + SC + + + + + + + + CL + + + + + + + + ER + + + + + + + + GA + + + + + + + + DO + + + + + + + + HB + + + + + + + + HU + + + + + + + + JR + + + + + + + QA + + + + + + + + SH + + + + + + + + EN + + + + + + + + FB + + + + + + + + K + + + + +`; diff --git a/__tests__/__snapshots__/campus-toggle.test.js.snap b/__tests__/__snapshots__/campus-toggle.test.js.snap index 6a9375b5..603a2d58 100644 --- a/__tests__/__snapshots__/campus-toggle.test.js.snap +++ b/__tests__/__snapshots__/campus-toggle.test.js.snap @@ -26,6 +26,7 @@ exports[`CampusToggle component should match snapshot 1`] = ` onResponderTerminationRequest={[Function]} onStartShouldSetResponder={[Function]} style={null} + testID="SGWButton" > { + await reloadApp(); +}); + +describe("CampusToggle: Toggling between campuses", () => { + it("should show the campus toggles", async () => { + await expect(element(by.id("SGWButton"))).toBeVisible(); + await expect(element(by.id("loyolaButton"))).toBeVisible(); + }); + + it("should show the Loyola campus on Loyola toggle press", async () => { + await element(by.id("loyolaButton")).tap(); + await expect(element(by.id("polygon" + BuildingId[BuildingId.VL]))).toExist(); + await expect(element(by.id("marker" + BuildingId[BuildingId.VL]))).toExist(); + }); + + it("should show the SGW campus on SGW toggle press", async () => { + await element(by.id("SGWButton")).tap(); + await expect(element(by.id("polygon" + BuildingId[BuildingId.H]))).toExist(); + await expect(element(by.id("marker" + BuildingId[BuildingId.H]))).toExist(); + }); +}); \ No newline at end of file diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js deleted file mode 100644 index 550777e8..00000000 --- a/e2e/firstTest.spec.js +++ /dev/null @@ -1,21 +0,0 @@ -const { reloadApp } = require("detox-expo-helpers"); - -describe("Example", () => { - beforeEach(async () => { - await reloadApp(); - }); - - it("should have welcome screen", async () => { - await expect(element(by.id("welcome"))).toBeVisible(); - }); - - it("should show hello screen after tap", async () => { - await element(by.id("hello_button")).tap(); - await expect(element(by.text("Hello!!!"))).toBeVisible(); - }); - - it("should show world screen after tap", async () => { - await element(by.id("world_button")).tap(); - await expect(element(by.text("World!!!"))).toBeVisible(); - }); -}); diff --git a/e2e/init.js b/e2e/init.js index 3f7788b2..0c88d29b 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -13,7 +13,10 @@ jasmine.getEnv().addReporter(adapter); jasmine.getEnv().addReporter(specReporter); beforeAll(async () => { - await detox.init(config); + await detox.init(config, {launchApp: false}); + await device.launchApp({permissions: { + location: "always" + }}); }, 300000); beforeEach(async () => { diff --git a/package.json b/package.json index 89229389..2599d423 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "eject": "expo eject", "ios": "expo start --ios", "start": "expo start", - "test": "jest --verbose --coverage", + "test": "jest __tests__ --verbose --coverage", + "e2e": "detox test", "web": "expo start --web", "lint": "tsc --noEmit && eslint --ext .ts,.tsx ./", "lint-fix": "tsc --noEmit && eslint --fix --ext .ts,.tsx ./", @@ -84,7 +85,7 @@ "ios.sim": { "binaryPath": "bin/Exponent.app", "type": "ios.simulator", - "name": "iPhone 8" + "name": "iPhone 11 Pro Max" } } } diff --git a/src/components/building-highlights/building-highlights.component.tsx b/src/components/building-highlights/building-highlights.component.tsx new file mode 100644 index 00000000..7e8d8595 --- /dev/null +++ b/src/components/building-highlights/building-highlights.component.tsx @@ -0,0 +1,73 @@ +import React, { useEffect, useState } from "react"; +import { Polygon, Marker } from "react-native-maps"; +import { Buildings } from "../../constants/buildings.data"; +import { BuildingId } from "../../types/main"; +import { View, Text, StyleSheet } from "react-native"; +import { CONCORDIA_RED, BUILDING_UNTAPPED } from "../../constants/style"; + +interface IProps { + onBuildingTap: (id: BuildingId) => void; + tappedBuilding: BuildingId; +} + +/** + * Wrapper Component for Polygons and Markers which overlay campus buildings. + */ +const BuildingHighlights = ({ onBuildingTap, tappedBuilding }: IProps) => { + /** + * Fill color for the Polygons + */ + const [fillColor, setFillColor] = useState(null); + const [tappedColor, setTappedColor] = useState(null); + useEffect(() => { + setFillColor(BUILDING_UNTAPPED); + setTappedColor(CONCORDIA_RED); + }, []); + + return ( + + {Buildings.map(building => ( + + {building.boundingBox.length > 0 ? ( + { + onBuildingTap(building.id); + }} + /> + ) : null} + + { + onBuildingTap(building.id); + }} + tracksViewChanges={false} + tracksInfoWindowChanges={false} + > + {BuildingId[building.id]} + + + ))} + + ); +}; + +const styles = StyleSheet.create({ + marker: { + backgroundColor: "#252525", + color: "#f0f0f0", + padding: 1, + borderRadius: 5 + } +}); + +export default BuildingHighlights; diff --git a/src/components/campus-toggle/campus-toggle.component.tsx b/src/components/campus-toggle/campus-toggle.component.tsx index ace39669..6dca8781 100644 --- a/src/components/campus-toggle/campus-toggle.component.tsx +++ b/src/components/campus-toggle/campus-toggle.component.tsx @@ -44,7 +44,11 @@ const CampusToggle = ({ onCampusToggle }: IProps) => { return ( - + @@ -57,7 +61,11 @@ const CampusToggle = ({ onCampusToggle }: IProps) => { - +