{
expect(resourceMapInfo.prop('currentLanguage')).toBe(defaultProps.currentLanguage);
});
- test('renders a ResourceMap', () => {
- const wrapper = getShowMapWrapper();
- const resourceMap = wrapper.find(ResourceMap);
- expect(resourceMap).toHaveLength(1);
- expect(resourceMap.prop('location')).toBe(defaultProps.location);
- expect(resourceMap.prop('resourceIds')).toEqual([defaultProps.resource.id]);
- expect(resourceMap.prop('selectedUnitId')).toBe(defaultProps.unit.id);
- expect(resourceMap.prop('showMap')).toBe(true);
- });
-
test('does not render a ResourceInfo', () => {
const wrapper = getShowMapWrapper();
const resourceInfo = wrapper.find(ResourceInfo);
diff --git a/app/pages/search/SearchPage.js b/app/pages/search/SearchPage.js
index 26808b996..4d1bb62ff 100644
--- a/app/pages/search/SearchPage.js
+++ b/app/pages/search/SearchPage.js
@@ -1,11 +1,12 @@
import isEqual from 'lodash/isEqual';
import PropTypes from 'prop-types';
-import React, { Component } from 'react';
+import React, { Component, lazy, Suspense } from 'react';
import { connect } from 'react-redux';
import queryString from 'query-string';
import { bindActionCreators } from 'redux';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
+import Loader from 'react-loader';
import { searchResources, toggleMap } from 'actions/searchActions';
import { changeSearchFilters } from 'actions/uiActions';
@@ -13,13 +14,14 @@ import { fetchPurposes } from 'actions/purposeActions';
import { fetchUnits } from 'actions/unitActions';
import PageWrapper from 'pages/PageWrapper';
import { injectT } from 'i18n';
-import ResourceMap from 'shared/resource-map';
import SearchControls from './controls';
import searchPageSelector from './searchPageSelector';
import SearchResults from './results/SearchResults';
import Sort from './Sort';
import MapToggle from './results/MapToggle';
+const ResourceMap = lazy(() => import('shared/resource-map'));
+
class UnconnectedSearchPage extends Component {
constructor(props) {
super(props);
@@ -119,14 +121,15 @@ class UnconnectedSearchPage extends Component {
{showMap && (
-
+ }>
+
+
)}
-
{(searchDone || isFetchingSearchResults) && (
{
expect(mapToggle.prop('contrast')).toBe('high-contrast');
});
- test('renders a ResourceMap with correct props', () => {
- const props = {
- searchResultIds: Immutable(['resource-1', 'resource-2']),
- selectedUnitId: '123',
- showMap: true,
- };
- const resourceMap = getWrapper(props).find(ResourceMap);
- expect(resourceMap).toHaveLength(1);
- expect(resourceMap.prop('showMap')).toBe(true);
- expect(resourceMap.prop('resourceIds')).toEqual(props.searchResultIds);
- expect(resourceMap.prop('selectedUnitId')).toBe(props.selectedUnitId);
- });
-
test('renders search results header', () => {
const header = getWrapper().find('.app-SearchPage__header');
expect(header).toHaveLength(1);