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 {
10
10
import {
11
11
buildFacetConfigFromConfig ,
12
12
buildSearchOptionsFromConfig ,
13
- getConfig
13
+ getConfig ,
14
+ getFacetFields ,
15
+ getSortFields
14
16
} from "./config/config-helper" ;
15
17
16
18
function createDriver ( ) {
@@ -49,7 +51,7 @@ class App extends Component {
49
51
} `}
50
52
>
51
53
< Header />
52
- < Body />
54
+ < Body hasSidebar = { getFacetFields ( ) . length > 0 || getSortFields ( ) . length > 0 ? true : false } />
53
55
</ div >
54
56
) }
55
57
</ SearchProvider >
Original file line number Diff line number Diff line change
1
+ import PropTypes from "prop-types" ;
1
2
import React from "react" ;
2
3
3
4
import {
@@ -9,17 +10,17 @@ import {
9
10
ResultsPerPage ,
10
11
Sorting
11
12
} from "../containers" ;
12
- import { getFacetFields , getSortFields , buildSortOptionsFromConfig } from "../config/config-helper" ;
13
+ import { buildSortOptionsFromConfig } from "../config/config-helper" ;
13
14
14
- export default function Body ( ) {
15
+ function Body ( { hasSidebar = true } ) {
15
16
return (
16
17
< div className = "reference-ui-body" >
17
18
< ErrorBoundary >
18
19
< div className = "initial-state-message" >
19
20
Type a search above to begin.
20
21
</ div >
21
22
< div className = "search-results" >
22
- < div className = { "sidebar" + ( getFacetFields ( ) . length > 0 || getSortFields ( ) . length > 0 ? '' : ' hidden' ) } >
23
+ < div className = { "sidebar" + ( hasSidebar ? '' : ' hidden' ) } >
23
24
< Sorting sortOptions = { buildSortOptionsFromConfig ( ) } />
24
25
< Facets />
25
26
</ div >
@@ -42,3 +43,9 @@ export default function Body() {
42
43
</ div >
43
44
) ;
44
45
}
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";
2
2
import Body from "./Body" ;
3
3
import { shallow } from "enzyme" ;
4
4
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 } /> ) ;
7
12
expect ( wrapper ) . toMatchSnapshot ( ) ;
8
13
} ) ;
Original file line number Diff line number Diff line change 1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
- exports [` renders correctly 1` ] = `
3
+ exports [` renders correctly with sidebar 1` ] = `
4
4
<div
5
5
className = " reference-ui-body"
6
6
>
@@ -57,3 +57,61 @@ exports[`renders correctly 1`] = `
57
57
</Component >
58
58
</div >
59
59
` ;
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