diff --git a/app/component/RoutePage.js b/app/component/RoutePage.js index a30650556f..a32a381d90 100644 --- a/app/component/RoutePage.js +++ b/app/component/RoutePage.js @@ -279,7 +279,6 @@ class RoutePage extends React.Component { route={route} onSelectChange={this.onPatternChange} gtfsId={route.gtfsId} - activeTab={activeTab} className={cx({ 'bp-large': breakpoint === 'large' })} /> )} diff --git a/app/component/RoutePatternSelect.js b/app/component/RoutePatternSelect.js index 3f314038ac..0925bc9e8c 100644 --- a/app/component/RoutePatternSelect.js +++ b/app/component/RoutePatternSelect.js @@ -24,7 +24,6 @@ class RoutePatternSelect extends Component { route: PropTypes.object, onSelectChange: PropTypes.func.isRequired, serviceDay: PropTypes.string.isRequired, - activeTab: PropTypes.string.isRequired, relay: PropTypes.object.isRequired, gtfsId: PropTypes.string.isRequired, }; @@ -49,15 +48,10 @@ class RoutePatternSelect extends Component { }; getOptions = () => { - const { activeTab, gtfsId, params, route } = this.props; + const { gtfsId, params, route } = this.props; const { router } = this.context; - const patterns = - activeTab === 'aikataulu' - ? route.patterns - : route.patterns.filter( - p => Array.isArray(p.tripsForDate) && p.tripsForDate.length > 0, - ); + const { patterns } = route; if (patterns.length === 0) { return null; @@ -96,14 +90,7 @@ class RoutePatternSelect extends Component { return this.state.loading === true ? (
) : ( -
o.tripsForDate && o.tripsForDate.length > 0, - ) === undefined && this.props.activeTab !== 'aikataulu', - })} - > +
{options && (options.length > 2 || options.length === 1) ? ( @@ -163,7 +150,6 @@ class RoutePatternSelect extends Component { } const defaultProps = { - activeTab: 'pysakit', className: 'bp-large', serviceDay: '20190306', relay: { diff --git a/test/unit/component/RoutePatternSelect.test.js b/test/unit/component/RoutePatternSelect.test.js index 738ed53f43..bbb74dac56 100644 --- a/test/unit/component/RoutePatternSelect.test.js +++ b/test/unit/component/RoutePatternSelect.test.js @@ -34,7 +34,7 @@ describe('', () => { expect(wrapper.find('#select-route-pattern > option')).to.have.lengthOf(3); }); - it('should render a toggle element with divs if there are only 2 patterns with trips', () => { + it('should render a toggle element with divs if there are no patterns with trips', () => { const props = { activeTab: 'pysakit', gtfsId: 'HSL:3002U', @@ -51,13 +51,13 @@ describe('', () => { code: 'HSL:3002U:0:01', headsign: 'Kauklahti', stops: [{ name: 'Helsinki' }, { name: 'Kauklahti' }], - tripsForDate: [{}], + tripsForDate: [], }, { code: 'HSL:3002U:0:02', headsign: 'Kirkkonummi', stops: [{ name: 'Helsinki' }, { name: 'Kirkkonummi' }], - tripsForDate: [{}], + tripsForDate: [], }, { code: 'HSL:3002U:0:03', @@ -71,8 +71,8 @@ describe('', () => { const wrapper = shallowWithIntl(, { context: { ...mockContext }, }); - expect(wrapper.find('option')).to.have.lengthOf(0); - expect(wrapper.find('div.route-option-togglable')).to.have.lengthOf(1); + expect(wrapper.find('option')).to.have.lengthOf(3); + expect(wrapper.find('div.route-option-togglable')).to.have.lengthOf(0); }); it('should redirect to the first existing pattern if there is no matching pattern available', () => {