serverSideSamplingStore.spec.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {Outcomes} from 'fixtures/js-stubs/outcomes';
  2. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  3. import {
  4. mockedSamplingDistribution,
  5. mockedSamplingSdkVersions,
  6. } from 'sentry/views/settings/project/server-side-sampling/testUtils';
  7. describe('ServerSideSamplingStore', function () {
  8. beforeEach(function () {
  9. ServerSideSamplingStore.reset();
  10. });
  11. afterEach(function () {
  12. jest.restoreAllMocks();
  13. });
  14. describe('distributionRequestSuccess()', function () {
  15. it('should load new sampling distribution values and trigger state', function () {
  16. jest.spyOn(ServerSideSamplingStore, 'trigger');
  17. expect(ServerSideSamplingStore.getState().distribution.data).toEqual(undefined);
  18. ServerSideSamplingStore.distributionRequestSuccess(mockedSamplingDistribution);
  19. expect(ServerSideSamplingStore.getState().distribution.data).toEqual(
  20. mockedSamplingDistribution
  21. );
  22. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  23. });
  24. });
  25. describe('sdkVersionsRequestSuccess()', function () {
  26. it('should load new sdk version values and trigger state', function () {
  27. jest.spyOn(ServerSideSamplingStore, 'trigger');
  28. expect(ServerSideSamplingStore.getState().sdkVersions.data).toEqual(undefined);
  29. ServerSideSamplingStore.sdkVersionsRequestSuccess(mockedSamplingSdkVersions);
  30. expect(ServerSideSamplingStore.getState().sdkVersions.data).toEqual(
  31. mockedSamplingSdkVersions
  32. );
  33. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  34. });
  35. });
  36. describe('projectStats48hRequestSuccess()', function () {
  37. it('should load project stats from the last 48h and trigger state', function () {
  38. jest.spyOn(ServerSideSamplingStore, 'trigger');
  39. expect(ServerSideSamplingStore.getState().projectStats48h.data).toEqual(undefined);
  40. ServerSideSamplingStore.projectStats48hRequestSuccess(Outcomes());
  41. expect(ServerSideSamplingStore.getState().projectStats48h.data).toEqual(Outcomes());
  42. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  43. });
  44. });
  45. describe('projectStats30dRequestSuccess()', function () {
  46. it('should load project stats from the last 30d and trigger state', function () {
  47. jest.spyOn(ServerSideSamplingStore, 'trigger');
  48. expect(ServerSideSamplingStore.getState().projectStats30d.data).toEqual(undefined);
  49. ServerSideSamplingStore.projectStats30dRequestSuccess(Outcomes());
  50. expect(ServerSideSamplingStore.getState().projectStats30d.data).toEqual(Outcomes());
  51. expect(ServerSideSamplingStore.trigger).toHaveBeenCalledTimes(1);
  52. });
  53. });
  54. });