serverSideSamplingStore.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  2. import {
  3. mockedSamplingDistribution,
  4. mockedSamplingSdkVersions,
  5. } from '../views/settings/project/server-side-sampling/utils';
  6. describe('ServerSideSamplingStore', function () {
  7. beforeEach(function () {
  8. ServerSideSamplingStore.reset();
  9. });
  10. afterEach(function () {
  11. jest.restoreAllMocks();
  12. });
  13. describe('loadSamplingDistributionSuccess()', function () {
  14. it('should load new sampling distribution values and trigger state', function () {
  15. jest.spyOn(ServerSideSamplingStore, 'trigger');
  16. expect(ServerSideSamplingStore.getState().samplingDistribution).toEqual({});
  17. ServerSideSamplingStore.loadSamplingDistributionSuccess(mockedSamplingDistribution);
  18. expect(ServerSideSamplingStore.getState().samplingDistribution).toEqual(
  19. mockedSamplingDistribution
  20. );
  21. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  22. });
  23. });
  24. describe('loadSamplingSdkVersionsSuccess()', function () {
  25. it('should load new sdk version values and trigger state', function () {
  26. jest.spyOn(ServerSideSamplingStore, 'trigger');
  27. expect(ServerSideSamplingStore.getState().samplingSdkVersions).toEqual([]);
  28. ServerSideSamplingStore.loadSamplingSdkVersionsSuccess(mockedSamplingSdkVersions);
  29. expect(ServerSideSamplingStore.getState().samplingSdkVersions).toEqual(
  30. mockedSamplingSdkVersions
  31. );
  32. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  33. });
  34. });
  35. });