Skip to content

Commit

Permalink
Add test to make sure Searcher's actions aren't decorated.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeyer2115 committed Sep 1, 2022
1 parent 53ff309 commit ce01533
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/SearchHeadlessProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock('@yext/search-headless', () => ({
provideHeadless: jest.fn(() => { return {}; })
}));

it('does not change anything about the supplied Headless instance', () => {
it('Provider does not invoke any methods or attributes of the Searcher', () => {
const config = {
apiKey: '<apiKey>',
experienceKey: '<experienceKey>',
Expand All @@ -16,4 +16,17 @@ it('does not change anything about the supplied Headless instance', () => {

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();
});

0 comments on commit ce01533

Please sign in to comment.