From 74e45204228f107ee61d4419ab9b1a0b821bca73 Mon Sep 17 00:00:00 2001 From: Sylvain Utard Date: Fri, 19 Aug 2016 12:14:04 +0200 Subject: [PATCH] fix(createAutocompleteSource): missing hitsPerPage forward (#313) Fix #308 --- src/createAutocompleteSource.js | 3 ++- src/createAutocompleteSource.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/createAutocompleteSource.js b/src/createAutocompleteSource.js index fed6a0ab2..8dae86494 100644 --- a/src/createAutocompleteSource.js +++ b/src/createAutocompleteSource.js @@ -6,6 +6,7 @@ export default function createAutocompleteSource({ clientOptions, apiKey, appId, + hitsPerPage, aroundLatLng, aroundRadius, aroundLatLngViaIP, @@ -28,7 +29,7 @@ export default function createAutocompleteSource({ const defaultQueryParams = { countries, - hitsPerPage: 5, + hitsPerPage: hitsPerPage || 5, language, type }; diff --git a/src/createAutocompleteSource.test.js b/src/createAutocompleteSource.test.js index 4a27bb7f7..a0de85101 100644 --- a/src/createAutocompleteSource.test.js +++ b/src/createAutocompleteSource.test.js @@ -84,6 +84,12 @@ describe('createAutocompleteSource', () => { expect(algoliasearch.__searchSpy).toBeCalledWith({...defaults, aroundRadius: 2000}); }); + it('supports hitsPerPage option', () => { + const {source, defaults} = setup({hitsPerPage: 2}); + source(defaults.query); + expect(algoliasearch.__searchSpy).toBeCalledWith({...defaults, hitsPerPage: 2}); + }); + it('supports useDeviceLocation option', () => { const latitude = '456'; const longitude = '789';