File tree 2 files changed +15
-1
lines changed
src/connectors/clear-refinements
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/clear-refin
21
21
` ) ;
22
22
} ) ;
23
23
24
+ it ( 'does not throw when widgetParams is not given' , ( ) => {
25
+ const customClearRefinements = connectClearRefinements ( ( ) => { } ) ;
26
+
27
+ expect ( ( ) => {
28
+ // @ts -expect-error widgetParams could be undefined
29
+ // because it's supposed to work without any.
30
+ customClearRefinements ( ) ;
31
+ } ) . not . toThrowError ( ) ;
32
+ } ) ;
33
+
24
34
it ( 'throws with both `includedAttributes` and `excludedAttributes`' , ( ) => {
25
35
const customClearRefinements = connectClearRefinements ( ( ) => { } ) ;
26
36
Original file line number Diff line number Diff line change @@ -94,7 +94,11 @@ const connectClearRefinements: ClearRefinementsConnector = function connectClear
94
94
transformItems = ( items => items ) as TransformItems < string > ,
95
95
} = widgetParams || { } ;
96
96
97
- if ( widgetParams . includedAttributes && widgetParams . excludedAttributes ) {
97
+ if (
98
+ widgetParams &&
99
+ widgetParams . includedAttributes &&
100
+ widgetParams . excludedAttributes
101
+ ) {
98
102
throw new Error (
99
103
withUsage (
100
104
'The options `includedAttributes` and `excludedAttributes` cannot be used together.'
You can’t perform that action at this time.
0 commit comments