-
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.
Rework the
SearchHeadlessProvider
to be a pass-through.
Per Product's request, the `SearchHeadlessProvider` is now a mere pass-through to the `SearchHeadlessContext.Provider`. Users will need to create and initialize a `Headless` instance themselves. The `acquireSessionId` utility will be moved to either the Component Library or Headless, TBD. The Jest test that was added ensures the `Provider` does not touch anything in the `Headless` instance. TEST=auto Ran all unit tests.
- Loading branch information
1 parent
9df8dd9
commit 53ff309
Showing
4 changed files
with
12 additions
and
93 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 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,19 @@ | ||
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 a search config with sandbox endpoints', () => { | ||
it('does not change anything about the supplied Headless instance', () => { | ||
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(); | ||
}); |
This file was deleted.
Oops, something went wrong.