Skip to content

Commit

Permalink
Round predictions instead of flooring them (#2219)
Browse files Browse the repository at this point in the history
* round instead of floor

* update tests
  • Loading branch information
anthonyshull authored Nov 13, 2024
1 parent d288e70 commit d8214d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/ts/helpers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const formatRelativeTime = (
return "<1 minute away";
}
if (seconds < secondsInHour) {
return `${Math.floor(seconds / secondsInMinute)} min`;
return `${Math.round(seconds / secondsInMinute)} min`;
}

return formatToBostonTime(time, "h:mm aa");
Expand Down
12 changes: 6 additions & 6 deletions assets/ts/stop/__tests__/DepartureListTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("DepartureList", () => {
);
expect(screen.queryAllByRole("listitem")).toHaveLength(predictions.length);
expect(container.querySelector(".c-svg__icon--realtime")).toBeTruthy();
expect(screen.queryByText("10 min")).toBeTruthy();
expect(screen.queryByText("11 min")).toBeTruthy();
});

it("should render a schedule when no predictions available", () => {
Expand All @@ -89,9 +89,9 @@ describe("DepartureList", () => {
);

expect(screen.queryAllByRole("listitem")).toHaveLength(schedules.length);
expect(screen.queryByText("9 min")).toBeTruthy();
expect(screen.queryByText("14 min")).toBeTruthy();
expect(screen.queryByText("19 min")).toBeTruthy();
expect(screen.queryByText("10 min")).toBeTruthy();
expect(screen.queryByText("15 min")).toBeTruthy();
expect(screen.queryByText("20 min")).toBeTruthy();
});

it("should render a prediction time if available", () => {
Expand All @@ -109,8 +109,8 @@ describe("DepartureList", () => {

expect(screen.queryAllByRole("listitem")).toHaveLength(schedules.length);
expect(screen.queryByText("<1 minute away")).toBeTruthy();
expect(screen.queryByText("10 min")).toBeTruthy();
expect(screen.queryByText("19 min")).toBeTruthy();
expect(screen.queryByText("11 min")).toBeTruthy();
expect(screen.queryByText("20 min")).toBeTruthy();
});

it("header has link to schedule page variant ", () => {
Expand Down

0 comments on commit d8214d9

Please sign in to comment.