@blaze-cms/react-page-builder 0.128.0-admin-updates.5 → 0.128.0-admin-updates.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +53 -24
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +3 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib/components/Image/Image.js +1 -1
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/helpers/check-if-should-render-banner.js +27 -5
- package/lib/components/List/components/helpers/check-if-should-render-banner.js.map +1 -1
- package/lib/components/List/components/helpers/index.js +8 -2
- package/lib/components/List/components/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +6 -1
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Range.js +9 -5
- package/lib/components/SearchFilter/components/Range.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +9 -5
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +9 -5
- package/lib/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib-es/components/Card/Card.js +1 -1
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Card/CardsContainer.js +59 -35
- package/lib-es/components/Card/CardsContainer.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +3 -1
- package/lib-es/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib-es/components/Image/Image.js +1 -1
- package/lib-es/components/Image/Image.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRender.js.map +1 -1
- package/lib-es/components/List/components/helpers/check-if-should-render-banner.js +29 -3
- package/lib-es/components/List/components/helpers/check-if-should-render-banner.js.map +1 -1
- package/lib-es/components/List/components/helpers/index.js +3 -2
- package/lib-es/components/List/components/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +6 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Range.js +9 -5
- package/lib-es/components/SearchFilter/components/Range.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +9 -5
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +9 -5
- package/lib-es/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Card/Card.js +2 -2
- package/src/components/Card/CardsContainer.js +54 -35
- package/src/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +1 -1
- package/src/components/Image/Image.js +1 -1
- package/src/components/List/components/Full/FullRender.js +0 -1
- package/src/components/List/components/helpers/check-if-should-render-banner.js +24 -3
- package/src/components/List/components/helpers/index.js +4 -2
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +0 -1
- package/src/components/SearchFilter/components/Checkbox.js +4 -0
- package/src/components/SearchFilter/components/Range.js +7 -4
- package/src/components/SearchFilter/components/Select.js +23 -17
- package/src/components/SearchFilter/components/TextSearch.js +30 -26
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +10 -10
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -8
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/__snapshots__/ItemDetailsSummary.test.js.snap +24 -4
- package/tests/unit/src/components/List/components/Cards/__snapshots__/CardsRender.test.js.snap +12 -12
- package/tests/unit/src/components/List/components/helpers/check-if-should-render-banner.test.js +59 -28
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Select from '@blaze-react/select';
|
|
4
|
-
import { withTitle } from '../../../HOC';
|
|
5
4
|
import { DEFAULT_OPTION } from '../constants';
|
|
6
5
|
|
|
7
6
|
const SelectFilter = ({
|
|
@@ -12,7 +11,8 @@ const SelectFilter = ({
|
|
|
12
11
|
filterValues,
|
|
13
12
|
shouldSearch,
|
|
14
13
|
displayLabelAsPlaceholder,
|
|
15
|
-
displayFilterCount
|
|
14
|
+
displayFilterCount,
|
|
15
|
+
elementTitle
|
|
16
16
|
}) => {
|
|
17
17
|
const filterValue = filterValues[prop] || '';
|
|
18
18
|
const disabledOptions = [];
|
|
@@ -35,20 +35,23 @@ const SelectFilter = ({
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
<>
|
|
39
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
40
|
+
<Select
|
|
41
|
+
label={labelToUse}
|
|
42
|
+
value={filterValue}
|
|
43
|
+
id={prop}
|
|
44
|
+
data-testid={`filter-${prop}`}
|
|
45
|
+
options={options}
|
|
46
|
+
defaultTextValue={defaultTextValue}
|
|
47
|
+
onChange={({ value }) => {
|
|
48
|
+
let valueToUse = value;
|
|
49
|
+
if (value === defaultTextValue) valueToUse = '';
|
|
50
|
+
updateFilterValues({ [prop]: valueToUse }, shouldSearch);
|
|
51
|
+
}}
|
|
52
|
+
disabled={disabledOptions}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
52
55
|
);
|
|
53
56
|
};
|
|
54
57
|
|
|
@@ -59,6 +62,8 @@ SelectFilter.propTypes = {
|
|
|
59
62
|
updateFilterValues: PropTypes.func.isRequired,
|
|
60
63
|
shouldSearch: PropTypes.bool,
|
|
61
64
|
label: PropTypes.string,
|
|
65
|
+
elementTitle: PropTypes.string,
|
|
66
|
+
|
|
62
67
|
displayLabelAsPlaceholder: PropTypes.bool,
|
|
63
68
|
displayFilterCount: PropTypes.bool
|
|
64
69
|
};
|
|
@@ -67,8 +72,9 @@ SelectFilter.defaultProps = {
|
|
|
67
72
|
filterValues: {},
|
|
68
73
|
shouldSearch: false,
|
|
69
74
|
label: '',
|
|
75
|
+
elementTitle: '',
|
|
70
76
|
displayLabelAsPlaceholder: false,
|
|
71
77
|
displayFilterCount: false
|
|
72
78
|
};
|
|
73
79
|
|
|
74
|
-
export default
|
|
80
|
+
export default SelectFilter;
|
|
@@ -2,45 +2,49 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Input from '@blaze-react/input';
|
|
4
4
|
import { MdSearch } from 'react-icons/md';
|
|
5
|
-
import { withTitle } from '../../../HOC';
|
|
6
5
|
import { SEARCH_TERM } from '../constants';
|
|
7
6
|
|
|
8
|
-
const TextSearch = ({ label, searchValue, updateFilterValues }) => (
|
|
9
|
-
|
|
10
|
-
<div className="
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const TextSearch = ({ label, searchValue, updateFilterValues, elementTitle }) => (
|
|
8
|
+
<>
|
|
9
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
10
|
+
<div className="search">
|
|
11
|
+
<div className="search__wrapper">
|
|
12
|
+
<div className="form-field form-field--input form-field--search">
|
|
13
|
+
<Input
|
|
14
|
+
id={SEARCH_TERM}
|
|
15
|
+
value={searchValue}
|
|
16
|
+
placeholder={label || 'Search'}
|
|
17
|
+
onChange={({ value: eValue }) => {
|
|
18
|
+
updateFilterValues({ [SEARCH_TERM]: eValue }, false);
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
className="icon-button icon-button--search"
|
|
25
|
+
onClick={e => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
updateFilterValues({ [SEARCH_TERM]: searchValue }, true);
|
|
28
|
+
}}>
|
|
29
|
+
<i>
|
|
30
|
+
<MdSearch />
|
|
31
|
+
</i>
|
|
32
|
+
</button>
|
|
20
33
|
</div>
|
|
21
|
-
<button
|
|
22
|
-
type="button"
|
|
23
|
-
className="icon-button icon-button--search"
|
|
24
|
-
onClick={e => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
updateFilterValues({ [SEARCH_TERM]: searchValue }, true);
|
|
27
|
-
}}>
|
|
28
|
-
<i>
|
|
29
|
-
<MdSearch />
|
|
30
|
-
</i>
|
|
31
|
-
</button>
|
|
32
34
|
</div>
|
|
33
|
-
|
|
35
|
+
</>
|
|
34
36
|
);
|
|
35
37
|
|
|
36
38
|
TextSearch.propTypes = {
|
|
37
39
|
searchValue: PropTypes.string.isRequired,
|
|
38
40
|
updateFilterValues: PropTypes.func.isRequired,
|
|
41
|
+
elementTitle: PropTypes.string,
|
|
39
42
|
label: PropTypes.string
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
TextSearch.defaultProps = {
|
|
46
|
+
elementTitle: '',
|
|
43
47
|
label: ''
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
export default
|
|
50
|
+
export default TextSearch;
|
|
@@ -30,7 +30,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
30
30
|
>
|
|
31
31
|
category-name
|
|
32
32
|
</a>
|
|
33
|
-
<
|
|
33
|
+
<div
|
|
34
34
|
class="card__title card__title--portrait "
|
|
35
35
|
>
|
|
36
36
|
<a
|
|
@@ -38,7 +38,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
38
38
|
>
|
|
39
39
|
mock name
|
|
40
40
|
</a>
|
|
41
|
-
</
|
|
41
|
+
</div>
|
|
42
42
|
<div
|
|
43
43
|
class="card__details card__details--portrait"
|
|
44
44
|
>
|
|
@@ -99,7 +99,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
99
99
|
<div
|
|
100
100
|
class="card__content card__content--portrait"
|
|
101
101
|
>
|
|
102
|
-
<
|
|
102
|
+
<div
|
|
103
103
|
class="card__title card__title--portrait "
|
|
104
104
|
>
|
|
105
105
|
<a
|
|
@@ -107,7 +107,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
107
107
|
>
|
|
108
108
|
mock name
|
|
109
109
|
</a>
|
|
110
|
-
</
|
|
110
|
+
</div>
|
|
111
111
|
<div
|
|
112
112
|
class="card__details card__details--portrait"
|
|
113
113
|
>
|
|
@@ -174,7 +174,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
174
174
|
>
|
|
175
175
|
category-name
|
|
176
176
|
</a>
|
|
177
|
-
<
|
|
177
|
+
<div
|
|
178
178
|
class="card__title card__title--portrait "
|
|
179
179
|
>
|
|
180
180
|
<a
|
|
@@ -182,7 +182,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
182
182
|
>
|
|
183
183
|
mock name
|
|
184
184
|
</a>
|
|
185
|
-
</
|
|
185
|
+
</div>
|
|
186
186
|
<div
|
|
187
187
|
class="card__details card__details--portrait"
|
|
188
188
|
>
|
|
@@ -248,7 +248,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
248
248
|
>
|
|
249
249
|
Pre header
|
|
250
250
|
</div>
|
|
251
|
-
<
|
|
251
|
+
<div
|
|
252
252
|
class="card__title card__title--portrait "
|
|
253
253
|
>
|
|
254
254
|
<a
|
|
@@ -256,7 +256,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
256
256
|
>
|
|
257
257
|
Alternative headline
|
|
258
258
|
</a>
|
|
259
|
-
</
|
|
259
|
+
</div>
|
|
260
260
|
<div
|
|
261
261
|
class="card__details card__details--portrait"
|
|
262
262
|
>
|
|
@@ -323,7 +323,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
323
323
|
>
|
|
324
324
|
category-name
|
|
325
325
|
</a>
|
|
326
|
-
<
|
|
326
|
+
<div
|
|
327
327
|
class="card__title card__title--portrait "
|
|
328
328
|
>
|
|
329
329
|
<a
|
|
@@ -331,7 +331,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
331
331
|
>
|
|
332
332
|
mock name
|
|
333
333
|
</a>
|
|
334
|
-
</
|
|
334
|
+
</div>
|
|
335
335
|
<div
|
|
336
336
|
class="card__details card__details--portrait"
|
|
337
337
|
>
|
|
@@ -36,7 +36,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
36
36
|
>
|
|
37
37
|
page
|
|
38
38
|
</div>
|
|
39
|
-
<
|
|
39
|
+
<div
|
|
40
40
|
class="card__title card__title--portrait "
|
|
41
41
|
>
|
|
42
42
|
<a
|
|
@@ -44,7 +44,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
44
44
|
>
|
|
45
45
|
Swan 78
|
|
46
46
|
</a>
|
|
47
|
-
</
|
|
47
|
+
</div>
|
|
48
48
|
</div>
|
|
49
49
|
<div
|
|
50
50
|
class="card__child-content"
|
|
@@ -73,7 +73,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
73
73
|
>
|
|
74
74
|
page
|
|
75
75
|
</div>
|
|
76
|
-
<
|
|
76
|
+
<div
|
|
77
77
|
class="card__title card__title--portrait "
|
|
78
78
|
>
|
|
79
79
|
<a
|
|
@@ -81,7 +81,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
81
81
|
>
|
|
82
82
|
Swan 98
|
|
83
83
|
</a>
|
|
84
|
-
</
|
|
84
|
+
</div>
|
|
85
85
|
</div>
|
|
86
86
|
<div
|
|
87
87
|
class="card__child-content"
|
|
@@ -123,7 +123,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
123
123
|
>
|
|
124
124
|
page
|
|
125
125
|
</div>
|
|
126
|
-
<
|
|
126
|
+
<div
|
|
127
127
|
class="card__title card__title--portrait "
|
|
128
128
|
>
|
|
129
129
|
<a
|
|
@@ -131,7 +131,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
131
131
|
>
|
|
132
132
|
Swan 78
|
|
133
133
|
</a>
|
|
134
|
-
</
|
|
134
|
+
</div>
|
|
135
135
|
</div>
|
|
136
136
|
<div
|
|
137
137
|
class="card__child-content"
|
|
@@ -160,7 +160,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
160
160
|
>
|
|
161
161
|
page
|
|
162
162
|
</div>
|
|
163
|
-
<
|
|
163
|
+
<div
|
|
164
164
|
class="card__title card__title--portrait "
|
|
165
165
|
>
|
|
166
166
|
<a
|
|
@@ -168,7 +168,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
168
168
|
>
|
|
169
169
|
Swan 98
|
|
170
170
|
</a>
|
|
171
|
-
</
|
|
171
|
+
</div>
|
|
172
172
|
</div>
|
|
173
173
|
<div
|
|
174
174
|
class="card__child-content"
|
|
@@ -13,12 +13,22 @@ exports[`ItemDetailsSummary component should render without throwing an error an
|
|
|
13
13
|
<span
|
|
14
14
|
class=""
|
|
15
15
|
>
|
|
16
|
-
|
|
16
|
+
<span
|
|
17
|
+
class="item-details-summary-label"
|
|
18
|
+
>
|
|
19
|
+
first
|
|
20
|
+
</span>
|
|
21
|
+
something
|
|
17
22
|
</span>
|
|
18
23
|
<span
|
|
19
24
|
class=""
|
|
20
25
|
>
|
|
21
|
-
|
|
26
|
+
<span
|
|
27
|
+
class="item-details-summary-label"
|
|
28
|
+
>
|
|
29
|
+
second
|
|
30
|
+
</span>
|
|
31
|
+
other thing
|
|
22
32
|
</span>
|
|
23
33
|
</div>
|
|
24
34
|
</DocumentFragment>
|
|
@@ -37,12 +47,22 @@ exports[`ItemDetailsSummary component should render without throwing an error if
|
|
|
37
47
|
<span
|
|
38
48
|
class=""
|
|
39
49
|
>
|
|
40
|
-
|
|
50
|
+
<span
|
|
51
|
+
class="item-details-summary-label"
|
|
52
|
+
>
|
|
53
|
+
first
|
|
54
|
+
</span>
|
|
55
|
+
something
|
|
41
56
|
</span>
|
|
42
57
|
<span
|
|
43
58
|
class=""
|
|
44
59
|
>
|
|
45
|
-
|
|
60
|
+
<span
|
|
61
|
+
class="item-details-summary-label"
|
|
62
|
+
>
|
|
63
|
+
second
|
|
64
|
+
</span>
|
|
65
|
+
other thing
|
|
46
66
|
</span>
|
|
47
67
|
</div>
|
|
48
68
|
</DocumentFragment>
|
package/tests/unit/src/components/List/components/Cards/__snapshots__/CardsRender.test.js.snap
CHANGED
|
@@ -25,11 +25,11 @@ exports[`CardsRender component should render based on listData received 1`] = `
|
|
|
25
25
|
<div
|
|
26
26
|
class="card__content card__content--portrait"
|
|
27
27
|
>
|
|
28
|
-
<
|
|
28
|
+
<div
|
|
29
29
|
class="card__title card__title--portrait "
|
|
30
30
|
>
|
|
31
31
|
item 1
|
|
32
|
-
</
|
|
32
|
+
</div>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
@@ -46,11 +46,11 @@ exports[`CardsRender component should render based on listData received 1`] = `
|
|
|
46
46
|
<div
|
|
47
47
|
class="card__content card__content--portrait"
|
|
48
48
|
>
|
|
49
|
-
<
|
|
49
|
+
<div
|
|
50
50
|
class="card__title card__title--portrait "
|
|
51
51
|
>
|
|
52
52
|
item 1
|
|
53
|
-
</
|
|
53
|
+
</div>
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
@@ -67,11 +67,11 @@ exports[`CardsRender component should render based on listData received 1`] = `
|
|
|
67
67
|
<div
|
|
68
68
|
class="card__content card__content--portrait"
|
|
69
69
|
>
|
|
70
|
-
<
|
|
70
|
+
<div
|
|
71
71
|
class="card__title card__title--portrait "
|
|
72
72
|
>
|
|
73
73
|
item 1
|
|
74
|
-
</
|
|
74
|
+
</div>
|
|
75
75
|
</div>
|
|
76
76
|
</div>
|
|
77
77
|
</div>
|
|
@@ -100,11 +100,11 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
|
|
|
100
100
|
<div
|
|
101
101
|
class="card__content card__content--portrait"
|
|
102
102
|
>
|
|
103
|
-
<
|
|
103
|
+
<div
|
|
104
104
|
class="card__title card__title--portrait "
|
|
105
105
|
>
|
|
106
106
|
item 1
|
|
107
|
-
</
|
|
107
|
+
</div>
|
|
108
108
|
</div>
|
|
109
109
|
</div>
|
|
110
110
|
</div>
|
|
@@ -121,11 +121,11 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
|
|
|
121
121
|
<div
|
|
122
122
|
class="card__content card__content--portrait"
|
|
123
123
|
>
|
|
124
|
-
<
|
|
124
|
+
<div
|
|
125
125
|
class="card__title card__title--portrait "
|
|
126
126
|
>
|
|
127
127
|
item 1
|
|
128
|
-
</
|
|
128
|
+
</div>
|
|
129
129
|
</div>
|
|
130
130
|
</div>
|
|
131
131
|
</div>
|
|
@@ -142,11 +142,11 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
|
|
|
142
142
|
<div
|
|
143
143
|
class="card__content card__content--portrait"
|
|
144
144
|
>
|
|
145
|
-
<
|
|
145
|
+
<div
|
|
146
146
|
class="card__title card__title--portrait "
|
|
147
147
|
>
|
|
148
148
|
item 1
|
|
149
|
-
</
|
|
149
|
+
</div>
|
|
150
150
|
</div>
|
|
151
151
|
</div>
|
|
152
152
|
</div>
|
package/tests/unit/src/components/List/components/helpers/check-if-should-render-banner.test.js
CHANGED
|
@@ -1,44 +1,75 @@
|
|
|
1
|
-
import checkIfShouldRenderBanner from '../../../../../../../src/components/List/components/helpers/check-if-should-render-banner';
|
|
1
|
+
import { checkIfShouldRenderBanner } from '../../../../../../../src/components/List/components/helpers/check-if-should-render-banner';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
const noInterval = checkIfShouldRenderBanner(1, {
|
|
10
|
-
interval: 2,
|
|
11
|
-
repeat: false,
|
|
12
|
-
hasBanner: false
|
|
13
|
-
});
|
|
14
|
-
const positionMatch = checkIfShouldRenderBanner(1, {
|
|
15
|
-
interval: 2,
|
|
16
|
-
repeat: false,
|
|
17
|
-
hasBanner: true
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const repeatOffMatch = checkIfShouldRenderBanner(3, {
|
|
21
|
-
interval: 2,
|
|
22
|
-
repeat: false,
|
|
23
|
-
hasBanner: true
|
|
24
|
-
});
|
|
25
|
-
const repeatOnMatch = checkIfShouldRenderBanner(3, {
|
|
26
|
-
interval: 2,
|
|
27
|
-
repeat: true,
|
|
28
|
-
hasBanner: true
|
|
29
|
-
});
|
|
3
|
+
const BANNER_MOCK = {
|
|
4
|
+
repeatEvery: 3,
|
|
5
|
+
startingPoint: 5,
|
|
6
|
+
maxRepetitions: 2
|
|
7
|
+
};
|
|
30
8
|
|
|
9
|
+
describe('checkIfShouldRenderBanner helper function', () => {
|
|
31
10
|
it('should return false if no interval or hasBanner is false', () => {
|
|
11
|
+
const noBanner = checkIfShouldRenderBanner(1, {
|
|
12
|
+
interval: 2,
|
|
13
|
+
repeat: false,
|
|
14
|
+
hasBanner: false
|
|
15
|
+
});
|
|
16
|
+
const noInterval = checkIfShouldRenderBanner(1, {
|
|
17
|
+
interval: 2,
|
|
18
|
+
repeat: false,
|
|
19
|
+
hasBanner: false
|
|
20
|
+
});
|
|
32
21
|
expect(noBanner).toBe(false);
|
|
33
22
|
expect(noInterval).toBe(false);
|
|
34
23
|
});
|
|
35
24
|
it('should return true if interval matches position', () => {
|
|
25
|
+
const positionMatch = checkIfShouldRenderBanner(1, {
|
|
26
|
+
interval: 2,
|
|
27
|
+
repeat: false,
|
|
28
|
+
hasBanner: true
|
|
29
|
+
});
|
|
36
30
|
expect(positionMatch).toBe(true);
|
|
37
31
|
});
|
|
38
32
|
it('should return false if repeat is false and position repeat mtaches', () => {
|
|
33
|
+
const repeatOffMatch = checkIfShouldRenderBanner(3, {
|
|
34
|
+
interval: 2,
|
|
35
|
+
repeat: false,
|
|
36
|
+
hasBanner: true
|
|
37
|
+
});
|
|
39
38
|
expect(repeatOffMatch).toBe(false);
|
|
40
39
|
});
|
|
41
40
|
it('should return true if repeat is true and position repeat mtaches', () => {
|
|
41
|
+
const repeatOnMatch = checkIfShouldRenderBanner(3, {
|
|
42
|
+
interval: 2,
|
|
43
|
+
repeat: true,
|
|
44
|
+
hasBanner: true
|
|
45
|
+
});
|
|
42
46
|
expect(repeatOnMatch).toBe(true);
|
|
43
47
|
});
|
|
48
|
+
|
|
49
|
+
it('should return false if no banner is present', () => {
|
|
50
|
+
const noBanner = checkIfShouldRenderBanner(1);
|
|
51
|
+
expect(noBanner).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should return false if index is lower than startingPoint', () => {
|
|
55
|
+
const lowIndex = checkIfShouldRenderBanner(3, BANNER_MOCK);
|
|
56
|
+
expect(lowIndex).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return true if index matches startingPoint', () => {
|
|
60
|
+
const startingPointMatch = checkIfShouldRenderBanner(4, BANNER_MOCK);
|
|
61
|
+
expect(startingPointMatch).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return true if repeat point matches and max repetitions hasnt been reached', () => {
|
|
65
|
+
const repetitionMatch = checkIfShouldRenderBanner(7, BANNER_MOCK);
|
|
66
|
+
const finalRepetitionMatch = checkIfShouldRenderBanner(10, BANNER_MOCK);
|
|
67
|
+
expect(repetitionMatch).toBe(true);
|
|
68
|
+
expect(finalRepetitionMatch).toBe(false);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should return false if repeat point matches and max repetitions has been reached', () => {
|
|
72
|
+
const maxRepetitionReached = checkIfShouldRenderBanner(13, BANNER_MOCK);
|
|
73
|
+
expect(maxRepetitionReached).toBe(false);
|
|
74
|
+
});
|
|
44
75
|
});
|