-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add an error event to monitor error from Algolia (#2642)
Fix #1585
- Loading branch information
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// import algoliaSearchHelper from 'algoliasearch-helper'; | ||
import InstantSearch from '../InstantSearch'; | ||
|
||
describe('InstantSearch lifecycle', () => { | ||
it('emits an error if the API returns an error', () => { | ||
const search = new InstantSearch({ | ||
// correct credentials so that the client does not retry | ||
appId: 'latency', | ||
apiKey: '6be0576ff61c053d5f9a3225e2a90f76', | ||
// the index name does not exist so that we get an error | ||
indexName: 'DOESNOTEXIST', | ||
}); | ||
|
||
let sendError; | ||
let reject; | ||
const waitForError = new Promise((resolve, r) => { | ||
sendError = resolve; | ||
reject = r; | ||
}); | ||
|
||
search.on('error', e => { | ||
try { | ||
expect(e).toEqual(expect.any(Error)); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
sendError(); | ||
}); | ||
|
||
search.addWidget({ | ||
render: () => {}, | ||
}); | ||
|
||
search.start(); | ||
|
||
return waitForError; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters