Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(store): throw an error if not constructed with a helper
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrutjes committed May 27, 2017
1 parent 37beb4e commit cbec746
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/__tests__/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ describe('Store', () => {
expect(store.algoliaHelper).toBe(helper);
});

test('should throw an exception if not constructed with a helper', () => {
expect(() => {
new Store({});
}).toThrow(TypeError);
});

test('should always use custom highlighting tags', () => {
const client = algoliaClient('app_id', 'api_key');
const helper = algoliaHelper(client);
Expand Down
7 changes: 5 additions & 2 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ const onHelperChange = function() {
};

export class Store {
constructor(algoliaHelper) {
constructor(helper) {
if (!(helper instanceof algoliaHelper.AlgoliaSearchHelper)) {
throw new TypeError('Expected an AlgoliaSearchHelper instance.');
}
// We require one start() call to execute the first search query.
// Allows every widget to alter the state at initialization
// without trigger multiple queries.
this._stoppedCounter = 1;

this.algoliaHelper = algoliaHelper;
this.algoliaHelper = helper;
}

set algoliaHelper(algoliaHelper) {
Expand Down

0 comments on commit cbec746

Please sign in to comment.