@@ -111,6 +111,36 @@ describe('DocSearch', () => {
111111 // Then
112112 expect ( actual . appId ) . toEqual ( 'foo' ) ;
113113 } ) ;
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+ } ) ;
114144 it ( 'should pass the input element as an instance property' , ( ) => {
115145 // Given
116146 let options = defaultOptions ;
@@ -128,15 +158,16 @@ describe('DocSearch', () => {
128158 // Given
129159 let options = {
130160 ...defaultOptions ,
131- algoliaOptions : 'algoliaOptions' ,
161+ algoliaOptions : { anOption : 42 } ,
132162 autocompleteOptions : 'autocompleteOptions'
133163 } ;
134164
135165 // When
136166 let actual = new DocSearch ( options ) ;
137167
138168 // Then
139- expect ( actual . algoliaOptions ) . toEqual ( 'algoliaOptions' ) ;
169+ expect ( typeof actual . algoliaOptions ) . toEqual ( 'object' ) ;
170+ expect ( actual . algoliaOptions . anOption ) . toEqual ( 42 ) ;
140171 expect ( actual . autocompleteOptions ) . toEqual ( 'autocompleteOptions' ) ;
141172 } ) ;
142173 it ( 'should instantiate algoliasearch with the correct values' , ( ) => {
@@ -294,8 +325,7 @@ describe('DocSearch', () => {
294325 docsearch = new DocSearch ( {
295326 indexName : 'indexName' ,
296327 apiKey : 'apiKey' ,
297- inputSelector : '#input' ,
298- algoliaOptions : 'algoliaOptions'
328+ inputSelector : '#input'
299329 } ) ;
300330 } ) ;
301331
@@ -327,7 +357,7 @@ describe('DocSearch', () => {
327357 let expectedArguments = {
328358 indexName : 'indexName' ,
329359 query : 'query' ,
330- params : 'algoliaOptions'
360+ params : { hitsPerPage : 5 }
331361 } ;
332362 expect ( client . search . calledWith ( [ expectedArguments ] ) ) . toBe ( true ) ;
333363 } ) ;
0 commit comments