Skip to content

Commit

Permalink
Merge d0b920e into 56e1a2f
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Aug 16, 2022
2 parents 56e1a2f + d0b920e commit cbd55ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite"
},
"dependencies": {
"@yext/search-headless": "^1.4.0",
"@yext/search-headless": "^2.0.0-alpha.130",
"use-sync-external-store": "^1.1.0"
},
"devDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions tests/useSearchState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ it('invoke useSearchState outside of SearchHeadlessProvider', () => {
it('Retrieves state snapshot during server side rendering and hydration process', () => {
const answers = createAnswersHeadless();
const mockedOnClick= jest.fn().mockImplementation(() => {
answers.setVertical('anotherFakeKey');
answers.setVertical('products');
});
function Test(): JSX.Element {
const verticalKey = useSearchState(state => state.vertical.verticalKey);
Expand All @@ -39,14 +39,14 @@ it('Retrieves state snapshot during server side rendering and hydration process'

const container = document.body.appendChild(document.createElement('div'));
container.innerHTML = renderOnServer();
userEvent.click(screen.getByText('fakeVerticalKey'));
userEvent.click(screen.getByText('people'));
expect(mockedOnClick).toBeCalledTimes(0);

//attach event listeners to the existing markup
render(<App />, { container, hydrate: true });
userEvent.click(screen.getByText('fakeVerticalKey'));
userEvent.click(screen.getByText('people'));
expect(mockedOnClick).toBeCalledTimes(1);
expect(screen.getByText('anotherFakeKey')).toBeDefined();
expect(screen.getByText('products')).toBeDefined();
});

it('does not perform extra renders/listener registrations for nested components', async () => {
Expand All @@ -60,7 +60,7 @@ it('does not perform extra renders/listener registrations for nested components'
}) || [];
parentStateUpdates.push(results);
const search = useCallback(() => {
actions.setQuery('iphone');
actions.setQuery('amani');
pendingVerticalQuery = actions.executeVerticalQuery();
}, [actions]);

Expand Down Expand Up @@ -221,9 +221,9 @@ describe('uses the most recent selector', () => {

function createAnswersHeadless() {
return provideHeadless({
apiKey: 'fake api key',
experienceKey: 'fake exp key',
apiKey: '2d8c550071a64ea23e263118a2b0680b',
experienceKey: 'slanswers',
locale: 'en',
verticalKey: 'fakeVerticalKey'
verticalKey: 'people'
});
}

0 comments on commit cbd55ef

Please sign in to comment.