serverSideSamplingStore.spec.tsx 2.7 KB

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