diff --git a/src/lib/DocSearch.js b/src/lib/DocSearch.js index ab493d07..ce4358d8 100644 --- a/src/lib/DocSearch.js +++ b/src/lib/DocSearch.js @@ -44,6 +44,12 @@ class DocSearch { this.algoliaOptions = algoliaOptions; this.autocompleteOptions = autocompleteOptions; + this.apiKey = apiKey; + this.indexName = indexName; + this.input = this.getInputFromSelector(inputSelector); + this.algoliaOptions = algoliaOptions; + this.autocompleteOptions = autocompleteOptions; + this.client = algoliasearch('BH4D9OD16A', this.apiKey); this.client.addAlgoliaAgent('docsearch.js ' + version); this.autocomplete = autocomplete(this.input, autocompleteOptions, [{ @@ -68,8 +74,6 @@ class DocSearch { } if (!DocSearch.getInputFromSelector(args.inputSelector)) { - throw new Error(`Error: No input element in the page matches ${args.inputSelector}`); - } } /** diff --git a/test/DocSearch-test.js b/test/DocSearch-test.js index 3aeafb1a..aef41582 100644 --- a/test/DocSearch-test.js +++ b/test/DocSearch-test.js @@ -227,6 +227,17 @@ describe('DocSearch', () => { // Given let selector = '.i-do-not-exist > at #all'; + DocSearch.prototype.checkArguments = checkArguments; + DocSearch.prototype.getInputFromSelector = getInputFromSelector; + + DocSearch.__Rewire__('algoliasearch', AlgoliaSearch); + DocSearch.__Rewire__('autocomplete', AutoComplete); + }); + + it('should call checkArguments', () => { + // Given + let options = defaultOptions; + // When let actual = getInputFromSelector(selector);