@@ -111,6 +111,36 @@ describe('DocSearch', () => {
111
111
// Then
112
112
expect ( actual . appId ) . toEqual ( 'foo' ) ;
113
113
} ) ;
114
+ it ( 'should allow customize algoliaOptions without loosing default options' , ( ) => {
115
+ // Given
116
+ let options = {
117
+ algoliaOptions : {
118
+ facetFilters : [ 'version:1.0' ]
119
+ } ,
120
+ ...defaultOptions
121
+ } ;
122
+
123
+ // When
124
+ let actual = new DocSearch ( options ) ;
125
+
126
+ // Then
127
+ expect ( actual . algoliaOptions ) . toEqual ( { hitsPerPage : 5 , facetFilters : [ 'version:1.0' ] } ) ;
128
+ } ) ;
129
+ it ( 'should allow customize hitsPerPage' , ( ) => {
130
+ // Given
131
+ let options = {
132
+ algoliaOptions : {
133
+ hitsPerPage : 10
134
+ } ,
135
+ ...defaultOptions
136
+ } ;
137
+
138
+ // When
139
+ let actual = new DocSearch ( options ) ;
140
+
141
+ // Then
142
+ expect ( actual . algoliaOptions ) . toEqual ( { hitsPerPage : 10 } ) ;
143
+ } ) ;
114
144
it ( 'should pass the input element as an instance property' , ( ) => {
115
145
// Given
116
146
let options = defaultOptions ;
@@ -128,15 +158,16 @@ describe('DocSearch', () => {
128
158
// Given
129
159
let options = {
130
160
...defaultOptions ,
131
- algoliaOptions : 'algoliaOptions' ,
161
+ algoliaOptions : { anOption : 42 } ,
132
162
autocompleteOptions : 'autocompleteOptions'
133
163
} ;
134
164
135
165
// When
136
166
let actual = new DocSearch ( options ) ;
137
167
138
168
// Then
139
- expect ( actual . algoliaOptions ) . toEqual ( 'algoliaOptions' ) ;
169
+ expect ( typeof actual . algoliaOptions ) . toEqual ( 'object' ) ;
170
+ expect ( actual . algoliaOptions . anOption ) . toEqual ( 42 ) ;
140
171
expect ( actual . autocompleteOptions ) . toEqual ( 'autocompleteOptions' ) ;
141
172
} ) ;
142
173
it ( 'should instantiate algoliasearch with the correct values' , ( ) => {
@@ -294,8 +325,7 @@ describe('DocSearch', () => {
294
325
docsearch = new DocSearch ( {
295
326
indexName : 'indexName' ,
296
327
apiKey : 'apiKey' ,
297
- inputSelector : '#input' ,
298
- algoliaOptions : 'algoliaOptions'
328
+ inputSelector : '#input'
299
329
} ) ;
300
330
} ) ;
301
331
@@ -327,7 +357,7 @@ describe('DocSearch', () => {
327
357
let expectedArguments = {
328
358
indexName : 'indexName' ,
329
359
query : 'query' ,
330
- params : 'algoliaOptions'
360
+ params : { hitsPerPage : 5 }
331
361
} ;
332
362
expect ( client . search . calledWith ( [ expectedArguments ] ) ) . toBe ( true ) ;
333
363
} ) ;
0 commit comments