useRouteAnalyticsParams.spec.tsx 811 B

12345678910111213141516171819202122232425262728
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider';
  3. import useRouteAnalyticsParams from './useRouteAnalyticsParams';
  4. function TestComponent() {
  5. useRouteAnalyticsParams({foo: 'bar'});
  6. return <div>hi</div>;
  7. }
  8. describe('useRouteAnalyticsParams', function () {
  9. it('calls setRouteAnalyticsParams', function () {
  10. const setRouteAnalyticsParams = jest.fn();
  11. render(
  12. <RouteAnalyticsContext.Provider
  13. value={{
  14. setRouteAnalyticsParams,
  15. setOrganization: jest.fn(),
  16. setDisableRouteAnalytics: jest.fn(),
  17. }}
  18. >
  19. <TestComponent />
  20. </RouteAnalyticsContext.Provider>
  21. );
  22. expect(setRouteAnalyticsParams).toHaveBeenCalledWith({foo: 'bar'});
  23. });
  24. });