Skip to content

Commit

Permalink
add test for no routes, change if expression
Browse files Browse the repository at this point in the history
  • Loading branch information
JHWelch committed Feb 19, 2024
1 parent 2871847 commit e4586a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
17 changes: 17 additions & 0 deletions __tests__/templates/MMM-CTA.njk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,20 @@ describe('multiple stops', () => {
expect(template).toContain('Train Stop');
});
});

describe('no stops', () => {
beforeEach(() => {
data = {
stops: [{
type: 'bus',
name: 'Bus Stop',
arrivals: [],
}],
};
template = nunjucks.render('MMM-CTA.njk', data);
});

it('shows no arrivals', () => {
expect(template).toContain('No scheduled arrivals.');
});
});
12 changes: 6 additions & 6 deletions templates/MMM-CTA.njk
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</tr>

<tr class="small">
{% if routeIcons %}
<th class="align-left"></th>
{% endif %}
{% if stop.arrivals[0].arrival %}
{% if stop.arrivals.length %}
{% if routeIcons %}
<th class="align-left"></th>
{% endif %}
<th class="align-left">
{{ "DIRECTION" | translate }}
</th>
Expand All @@ -38,7 +38,7 @@
</tr>
</thead>
<tbody>
{% if stop.arrivals[0].arrival %}
{% if stop.arrivals.length %}
{% for arrival in stop.arrivals %}
<tr class="small">
{% if routeIcons %}
Expand All @@ -61,7 +61,7 @@
</tr>
{% endfor %}
{% else %}
<td class="small">No planned arrivals.</td>
<td class="small">No scheduled arrivals.</td>
{% endif %}
</tbody>
</table>
Expand Down

0 comments on commit e4586a1

Please sign in to comment.