import AlgoliaInsights from './../insights' const credentials = { apiKey: 'test', applicationID: 'test' } describe('Click without init', () => { it('Should throw if init was not called', () => { expect(() => { AlgoliaInsights.click() }).toThrowError('Before calling any methods on the analytics, you first need to call the \'init\' function with applicationID and apiKey parameters') }) }); describe('Wrong params', () => { beforeAll(() => { AlgoliaInsights.init(credentials); }) it('Should throw if objectID and position are not sent', () => { expect(() => { AlgoliaInsights.click() }).toThrowError('No params were sent to click function, please provide an objectID and position to be reported') }) it('Should throw if objectID is not sent', () => { expect(() => { AlgoliaInsights.click({objectID: 1}) }).toThrowError('required position parameter was not sent, click event position can not be properly sent without') }) it('Should throw if position is not sent', () => { expect(() => { AlgoliaInsights.click({position: 1}) }).toThrowError('required objectID parameter was not sent, click event can not be properly attributed') }) it('Should properly pass queryID ', () => { const params = AlgoliaInsights.click({position: 1, objectID: '1234', queryID: 'queryIDString'}) expect(params.queryID).toEqual('queryIDString') }) })