Skip to content

Commit

Permalink
fix commuter rail tooltip, add test set
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen committed Dec 20, 2019
1 parent e2baa79 commit e38a776
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
54 changes: 54 additions & 0 deletions apps/site/assets/ts/schedule/__tests__/LineDiagramTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,41 @@ export const lineDiagram = [
},
alerts: []
},
{
stop_data: [{ type: "stop", branch: "Lowell" }],
route_stop: {
zone: "",
stop_features: [],
station_info: {},
route: {
type: 1,
name: "Orange Line",
long_name: "Orange Line",
id: "Orange",
direction_names: { "0": "Southbound", "1": "Northbound" },
direction_destinations: { "0": "Forest Hills", "1": "Oak Grove" },
description: "rapid_transit",
"custom_route?": false
},
name: "Tufts Medical Center",
"is_terminus?": false,
"is_beginning?": false,
id: "place-tufts",
connections: [
{
type: 3,
name: "SL1",
long_name: "Silver Line",
id: "741",
description: "rapid_transit",
"custom_route?": false
},
],
closed_stop_info: null,
branch: null
},
alerts: []
},
{
stop_data: [{ type: "stop", branch: "Lowell" }],
route_stop: {
Expand Down Expand Up @@ -519,4 +554,23 @@ describe("LineDiagram", () => {
expect(Object.entries(props)).toContainEqual(["data-toggle", "tooltip"]);
});
});

it.each`
index | expectedNames
${0} | ${["Route 110"]}
${1} | ${["Silver Line SL1"]}
${2} | ${["Orange Line", "Green Line C", "Green Line E", "Commuter Rail"]}
${3} | ${["Route 62", "Route 67", "Route 76", "Route 79", "Route 84", "Route 350", "Route 351"]}
`(
"has appropriate tooltip content for stop $index",
({ index, expectedNames }) => {
const wrapper = mount(<LineDiagram lineDiagram={lineDiagram} />);
const connections = wrapper
.find(".m-schedule-line-diagram__connections")
.at(index);

const names = connections.find("a").map(c => c.props().title);
expect(names).toEqual(expectedNames);
}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,50 @@ Array [
/>
</div>
</div>,
<div
className="m-schedule-line-diagram__stop"
>
<div
className="m-schedule-line-diagram__card-left"
>
<div
className="m-schedule-line-diagram__stop-name"
>
<a
href="/stops/place-tufts"
>
<h4>
Tufts Medical Center
</h4>
</a>
</div>
<div
className="m-schedule-line-diagram__connections"
>
<a
data-animation="false"
data-original-title="Silver Line SL1"
data-placement="bottom"
data-selector="true"
data-toggle="tooltip"
data-trigger="focus"
href="/schedules/741/line"
title="Silver Line SL1"
>
<span
className="c-icon__bus-pill--small m-schedule-line-diagram__connection u-bg--silver-line"
>
SL1
</span>
</a>
</div>
</div>
<div>
<div
className="m-schedule-line-diagram__features"
/>
</div>
</div>,
<div
className="m-schedule-line-diagram__stop"
>
Expand Down Expand Up @@ -143,13 +187,13 @@ Array [
</a>
<a
data-animation="false"
data-original-title="Fitchburg Line"
data-original-title="Commuter Rail"
data-placement="bottom"
data-selector="true"
data-toggle="tooltip"
data-trigger="focus"
href="/schedules/CR-Fitchburg/line"
title="Fitchburg Line"
title="Commuter Rail"
>
<span
className="m-schedule-line-diagram__connection"
Expand Down
4 changes: 4 additions & 0 deletions apps/site/assets/ts/schedule/components/LineDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const connectionName = (connection: Route): string => {
: `Route ${connection.name}`;
}

if (connection.type === 2) {
return "Commuter Rail";
}

return connection.name;
};

Expand Down

0 comments on commit e38a776

Please sign in to comment.