File tree Expand file tree Collapse file tree 4 files changed +80
-8
lines changed Expand file tree Collapse file tree 4 files changed +80
-8
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ import {
1010import {
1111 buildFacetConfigFromConfig ,
1212 buildSearchOptionsFromConfig ,
13- getConfig
13+ getConfig ,
14+ getFacetFields ,
15+ getSortFields
1416} from "./config/config-helper" ;
1517
1618function createDriver ( ) {
@@ -49,7 +51,7 @@ class App extends Component {
4951 } `}
5052 >
5153 < Header />
52- < Body />
54+ < Body hasSidebar = { getFacetFields ( ) . length > 0 || getSortFields ( ) . length > 0 ? true : false } />
5355 </ div >
5456 ) }
5557 </ SearchProvider >
Original file line number Diff line number Diff line change 1+ import PropTypes from "prop-types" ;
12import React from "react" ;
23
34import {
@@ -9,17 +10,17 @@ import {
910 ResultsPerPage ,
1011 Sorting
1112} from "../containers" ;
12- import { getFacetFields , getSortFields , buildSortOptionsFromConfig } from "../config/config-helper" ;
13+ import { buildSortOptionsFromConfig } from "../config/config-helper" ;
1314
14- export default function Body ( ) {
15+ function Body ( { hasSidebar = true } ) {
1516 return (
1617 < div className = "reference-ui-body" >
1718 < ErrorBoundary >
1819 < div className = "initial-state-message" >
1920 Type a search above to begin.
2021 </ div >
2122 < div className = "search-results" >
22- < div className = { "sidebar" + ( getFacetFields ( ) . length > 0 || getSortFields ( ) . length > 0 ? '' : ' hidden' ) } >
23+ < div className = { "sidebar" + ( hasSidebar ? '' : ' hidden' ) } >
2324 < Sorting sortOptions = { buildSortOptionsFromConfig ( ) } />
2425 < Facets />
2526 </ div >
@@ -42,3 +43,9 @@ export default function Body() {
4243 </ div >
4344 ) ;
4445}
46+
47+ Body . propTypes = {
48+ hasSidebar : PropTypes . bool
49+ } ;
50+
51+ export default Body ;
Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ import React from "react";
22import Body from "./Body" ;
33import { shallow } from "enzyme" ;
44
5- it ( "renders correctly" , ( ) => {
6- const wrapper = shallow ( < Body /> ) ;
5+ it ( "renders correctly with sidebar" , ( ) => {
6+ const wrapper = shallow ( < Body hasSidebar = { true } /> ) ;
7+ expect ( wrapper ) . toMatchSnapshot ( ) ;
8+ } ) ;
9+
10+ it ( "renders correctly without the sidebar" , ( ) => {
11+ const wrapper = shallow ( < Body hasSidebar = { false } /> ) ;
712 expect ( wrapper ) . toMatchSnapshot ( ) ;
813} ) ;
Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
3- exports [` renders correctly 1` ] = `
3+ exports [` renders correctly with sidebar 1` ] = `
44<div
55 className = " reference-ui-body"
66>
@@ -57,3 +57,61 @@ exports[`renders correctly 1`] = `
5757 </Component >
5858</div >
5959` ;
60+
61+ exports [` renders correctly without the sidebar 1` ] = `
62+ <div
63+ className = " reference-ui-body"
64+ >
65+ <Component >
66+ <div
67+ className = " initial-state-message"
68+ >
69+ Type a search above to begin.
70+ </div >
71+ <div
72+ className = " search-results"
73+ >
74+ <div
75+ className = " sidebar hidden"
76+ >
77+ <Component
78+ sortOptions = {
79+ Array [
80+ Object {
81+ " direction" : " " ,
82+ " name" : " Relevance" ,
83+ " value" : " " ,
84+ },
85+ ]
86+ }
87+ />
88+ <Component />
89+ </div >
90+ <div
91+ className = " results"
92+ >
93+ <div
94+ className = " results__header"
95+ >
96+ <div
97+ className = " meta"
98+ >
99+ <Component />
100+ <Component />
101+ </div >
102+ </div >
103+ <div
104+ className = " results__body"
105+ >
106+ <Component />
107+ </div >
108+ <div
109+ className = " results__footer"
110+ >
111+ <Component />
112+ </div >
113+ </div >
114+ </div >
115+ </Component >
116+ </div >
117+ ` ;
You can’t perform that action at this time.
0 commit comments