-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Version 2.0.0 ### Breaking Changes - Upgraded search-headless dependency to V2. This means re-exported interfaces related to static filters and direct answers stems from search-headless V1 have been changed or removed in headless-react V2. - for more details, see the breaking changes listed in V2 [release notes](https://github.com/yext/search-headless/releases/tag/v2.0.0) and [documentation](https://github.com/yext/search-headless/blob/main/docs/search-headless.md) of search-headless - `SearchHeadlessProvider` now takes in a `SearchHeadless` instance instead of a `SearchConfig` object. `SearchHeadlessProvider` will also no longer set vertical key, session tracking, and session id for the `SearchHeadless` instance. Users will need to create and initialize a Headless instance themselves. For more context, this change is made to prevent potential memory leaks, per Redux's recommendation that redux store (i.e. `SearchHeadless` instance) should not be instantiated within a render function. (#156) - All exports marked as `@deprecated` in previous publish as part of the rebranding process, as well as `subscribeToStateUpdates`, is now removed in V2 (#153 ) - for more details, the deprecated identifiers are listed in [v1.3 release notes](https://github.com/yext/search-headless-react/releases/tag/v1.3.0)
- Loading branch information
Showing
13 changed files
with
77 additions
and
253 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { SearchHeadlessProvider, SandboxEndpoints } from '../src'; | ||
import { SearchHeadlessProvider } from '../src'; | ||
import { render } from '@testing-library/react'; | ||
import { provideHeadless } from '@yext/search-headless'; | ||
import { provideHeadless, SearchHeadless } from '@yext/search-headless'; | ||
|
||
jest.mock('@yext/search-headless', () => ({ | ||
provideHeadless: jest.fn(() => ({ | ||
setSessionTrackingEnabled: jest.fn(), | ||
setSessionId: jest.fn() | ||
})) | ||
provideHeadless: jest.fn(() => { return {}; }) | ||
})); | ||
|
||
it('correctly passes through an answers config with sandbox endpoints', () => { | ||
it('Provider does not invoke any methods or attributes of the Searcher', () => { | ||
const config = { | ||
apiKey: '<apiKey>', | ||
experienceKey: '<experienceKey>', | ||
locale: 'en', | ||
endpoints: SandboxEndpoints | ||
locale: 'en' | ||
}; | ||
const searcher: SearchHeadless = provideHeadless(config); | ||
|
||
render(<SearchHeadlessProvider {...config}/>); | ||
expect(provideHeadless).toHaveBeenCalledTimes(1); | ||
expect(provideHeadless).toHaveBeenCalledWith(config, expect.anything()); | ||
expect( | ||
() => render(<SearchHeadlessProvider searcher={searcher}></SearchHeadlessProvider>)).not.toThrowError(); | ||
}); | ||
|
||
it('Provider does decorate any methods in the Searcher', () => { | ||
const config = { | ||
apiKey: '<apiKey>', | ||
experienceKey: '<experienceKey>', | ||
locale: 'en' | ||
}; | ||
const searcher: SearchHeadless = provideHeadless(config); | ||
const searcherProxy = new Proxy(searcher, { set() { throw new Error(); } }); | ||
|
||
expect(() => render( | ||
<SearchHeadlessProvider searcher={searcherProxy}></SearchHeadlessProvider>)).not.toThrowError(); | ||
}); |
Oops, something went wrong.