From ce0153369669e9ad5dc4c0af7e3bd03749b997ea Mon Sep 17 00:00:00 2001 From: Tom Meyer Date: Thu, 1 Sep 2022 11:27:06 -0400 Subject: [PATCH] Add test to make sure Searcher's actions aren't decorated. --- tests/SearchHeadlessProvider.test.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/SearchHeadlessProvider.test.tsx b/tests/SearchHeadlessProvider.test.tsx index 4ac6c6f..1b5ef5f 100644 --- a/tests/SearchHeadlessProvider.test.tsx +++ b/tests/SearchHeadlessProvider.test.tsx @@ -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: '', experienceKey: '', @@ -16,4 +16,17 @@ it('does not change anything about the supplied Headless instance', () => { expect( () => render()).not.toThrowError(); +}); + +it('Provider does decorate any methods in the Searcher', () => { + const config = { + apiKey: '', + experienceKey: '', + locale: 'en' + }; + const searcher: SearchHeadless = provideHeadless(config); + const searcherProxy = new Proxy(searcher, { set() { throw new Error(); } }); + + expect(() => render( + )).not.toThrowError(); }); \ No newline at end of file