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
56 changes: 56 additions & 0 deletions apps/mobile/__tests__/notifications-screen.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { fireEvent, render } from "@testing-library/react-native";

import {
NotificationsScreen,
type PriceAlert,
} from "../features/notifications/NotificationsScreen";

describe("NotificationsScreen", () => {
it("shows example price-drop alerts and lets the user toggle an alert locally", async () => {
const screen = await render(<NotificationsScreen />);

expect(screen.getByText("Nintendo Switch 2")).toBeTruthy();
expect(
screen.getByText("Price dropped from $499.99 to $449.99"),
).toBeTruthy();

const alertToggle = screen.getByRole("switch", {
name: "Nintendo Switch 2 price alert",
});
expect(alertToggle.props.value).toBe(true);

await fireEvent(alertToggle, "valueChange", false);

expect(
screen.getByRole("switch", { name: "Nintendo Switch 2 price alert" })
.props.value,
).toBe(false);
});

it("shows an empty state when no price alerts are available", async () => {
const alerts: PriceAlert[] = [];
const screen = await render(<NotificationsScreen alerts={alerts} />);

expect(screen.getByText("No price alerts yet")).toBeTruthy();
expect(
screen.getByText(
"Watch an item and set a target price to see alerts here.",
),
).toBeTruthy();
});

it("lets the user toggle notification settings locally", async () => {
const screen = await render(<NotificationsScreen />);
const priceDropToggle = screen.getByRole("switch", {
name: "Price drop notifications",
});

expect(priceDropToggle.props.value).toBe(true);
await fireEvent(priceDropToggle, "valueChange", false);

expect(
screen.getByRole("switch", { name: "Price drop notifications" }).props
.value,
).toBe(false);
});
});
7 changes: 6 additions & 1 deletion apps/mobile/app/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ import { HomeScreen } from "../features/home/HomeScreen";
export default function HomeRoute() {
const router = useRouter();

return <HomeScreen onLogout={() => router.replace("/")} />;
return (
<HomeScreen
onLogout={() => router.replace("/")}
onOpenNotifications={() => router.push("/notifications")}
/>
);
}
5 changes: 5 additions & 0 deletions apps/mobile/app/notifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NotificationsScreen } from "../features/notifications/NotificationsScreen";

export default function NotificationsRoute() {
return <NotificationsScreen />;
}
Loading
Loading