projects.spec.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {_debouncedLoadStats} from 'sentry/actionCreators/projects';
  2. import {Client} from 'sentry/api';
  3. describe('Projects ActionCreators', function () {
  4. const api = new Client();
  5. const organization = TestStubs.Organization();
  6. let mock;
  7. it('loadStatsForProject', function () {
  8. jest.useFakeTimers();
  9. mock = MockApiClient.addMockResponse({
  10. url: '/organizations/org-slug/projects/',
  11. });
  12. expect(mock).not.toHaveBeenCalled();
  13. _debouncedLoadStats(api, new Set([...Array(50)].map((_, i) => i)), {
  14. orgId: organization.slug,
  15. });
  16. expect(mock).toHaveBeenCalledTimes(5);
  17. expect(mock).toHaveBeenLastCalledWith(
  18. '/organizations/org-slug/projects/',
  19. expect.objectContaining({
  20. query: {
  21. statsPeriod: '24h',
  22. query: 'id:40 id:41 id:42 id:43 id:44 id:45 id:46 id:47 id:48 id:49',
  23. },
  24. })
  25. );
  26. });
  27. it('loadStatsForProject() with additional query', function () {
  28. jest.useFakeTimers();
  29. mock = MockApiClient.addMockResponse({
  30. url: '/organizations/org-slug/projects/',
  31. });
  32. expect(mock).not.toHaveBeenCalled();
  33. _debouncedLoadStats(api, new Set([1, 2, 3]), {
  34. orgId: organization.slug,
  35. query: {transactionStats: '1'},
  36. });
  37. expect(mock).toHaveBeenCalledTimes(1);
  38. expect(mock).toHaveBeenLastCalledWith(
  39. '/organizations/org-slug/projects/',
  40. expect.objectContaining({
  41. query: {
  42. statsPeriod: '24h',
  43. query: 'id:1 id:2 id:3',
  44. transactionStats: '1',
  45. },
  46. })
  47. );
  48. });
  49. });