useDisableRouteAnalytics.spec.tsx 782 B

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