Skip to content
Merged
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
92 changes: 92 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run npm test",
"type": "shell",
"command": "npm",
"args": [
"test"
],
"isBackground": false,
"problemMatcher": [
"$mocha"
],
"group": "test"
},
{
"label": "Run npm test after test updates",
"type": "shell",
"command": "npm",
"args": [
"test"
],
"isBackground": false,
"problemMatcher": [
"$mocha"
],
"group": "test"
},
{
"label": "Run npm test after fixing accessibility label tests",
"type": "shell",
"command": "npm",
"args": [
"test"
],
"isBackground": false,
"problemMatcher": [
"$mocha"
],
"group": "test"
},
{
"label": "Run npm test after fixing test nesting and params",
"type": "shell",
"command": "npm",
"args": [
"test"
],
"isBackground": false,
"problemMatcher": [
"$mocha"
],
"group": "test"
},
{
"label": "Run npm test with verbose output for diagnostics",
"type": "shell",
"command": "npm",
"args": [
"test",
"--",
"--verbose"
],
"isBackground": false,
"problemMatcher": [
"$mocha"
],
"group": "test"
},
{
"label": "Run Jest tests with verbose output",
"type": "shell",
"command": "npm test -- --verbose",
"isBackground": false,
"problemMatcher": [
"$tsc"
],
"group": "test"
},
{
"label": "Run Jest tests with verbose output",
"type": "shell",
"command": "npm test -- --verbose",
"isBackground": false,
"problemMatcher": [
"$tsc"
],
"group": "test"
}
]
}
49 changes: 47 additions & 2 deletions __tests__/CampusMapScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ jest.mock("../components/NavigationBar", () => {
return (
<View>
<Text testID="nav-visible">{props.visible ? "visible" : "hidden"}</Text>
<Pressable
testID="accessible-mode-toggle"
value={props.accessibleOnly}
onPress={() => props.onAccessibleOnlyChange?.(!props.accessibleOnly)}
>
<Text>Toggle Accessibility</Text>
</Pressable>
<Text testID="nav-use-my-location-result">
{result ? JSON.stringify(result) : "null"}
</Text>
Expand All @@ -198,20 +205,33 @@ jest.mock("../components/NavigationBar", () => {
mode: "walking",
label: "Walk",
icon: "walk",
})
}, null, null, false)
}
>
<Text>Confirm</Text>
</Pressable>

<Pressable
testID="nav-confirm-accessible"
onPress={() =>
props.onConfirm("H", "MB", {
mode: "walking",
label: "Walk",
icon: "walk",
}, null, null, true)
}
>
<Text>Confirm Accessible</Text>
</Pressable>

<Pressable
testID="nav-confirm-nullstart"
onPress={() =>
props.onConfirm(null, "MB", {
mode: "walking",
label: "Walk",
icon: "walk",
})
}, null, null, false)
}
>
<Text>Confirm Null Start</Text>
Expand Down Expand Up @@ -917,6 +937,7 @@ describe("CampusMapScreen", () => {
floors: JSON.stringify([1, 2, 8]),
navOrigin: "H-110",
navDest: "H-920",
accessibleOnly: "false",
},
});
expect(screen.getByTestId("nav-visible").props.children).toBe("hidden");
Expand All @@ -934,6 +955,7 @@ describe("CampusMapScreen", () => {
buildingName: "H",
floors: JSON.stringify([1, 2, 8]),
roomQuery: "H-920",
accessibleOnly: "false",
},
});
expect(screen.getByTestId("nav-visible").props.children).toBe("hidden");
Expand Down Expand Up @@ -1140,6 +1162,7 @@ describe("CampusMapScreen", () => {
buildingName: "MB",
floors: JSON.stringify([1, -2]),
roomQuery: "MB-1.210",
accessibleOnly: "false",
},
});
});
Expand All @@ -1156,6 +1179,7 @@ describe("CampusMapScreen", () => {
params: {
buildingName: "H",
floors: JSON.stringify([1, 2, 8]),
accessibleOnly: "false",
},
});
});
Expand Down Expand Up @@ -1295,10 +1319,30 @@ describe("CampusMapScreen", () => {
params: {
buildingName: "H",
floors: JSON.stringify([1, 2, 8]),
accessibleOnly: "false",
},
});
});

it("passes accessibleOnly true to IndoorMapScreen when accessibility mode is on", async () => {
(useLocalSearchParams as jest.Mock).mockReturnValue({});
await renderScreen();

fireEvent.press(screen.getByTestId("accessible-mode-toggle"));

expect(screen.getByTestId("accessible-mode-toggle").props.value).toBe(true);

fireEvent.press(screen.getByTestId("nav-confirm-accessible"));
Comment thread
NicG27 marked this conversation as resolved.
fireEvent.press(screen.getByTestId("trigger-popup-open-indoor"));

expect(router.push).toHaveBeenCalledWith({
pathname: "/IndoorMapScreen",
params: expect.objectContaining({
accessibleOnly: "true",
}),
});
});

it("uses the same normalized indoor route when opening from the building popup flow", async () => {
(useLocalSearchParams as jest.Mock).mockReturnValue({});
await renderScreen();
Expand All @@ -1310,6 +1354,7 @@ describe("CampusMapScreen", () => {
params: {
buildingName: "H",
floors: JSON.stringify([1, 2, 8]),
accessibleOnly: "false",
},
});
});
Expand Down
Loading
Loading