1
0
Fork 0

test(DocSearch): Add tests for constructor

This commit is contained in:
Pixelastic 2015-12-17 16:24:38 +01:00
parent e749465f3b
commit 6780cbcfb1
2 changed files with 17 additions and 2 deletions

View file

@ -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}`);
}
}
/**

View file

@ -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);