mockTimelineVisualization.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {MockTimelineVisualization} from 'sentry/views/monitors/components/mockTimelineVisualization';
  4. jest.mock('sentry/utils/useDimensions', () => ({
  5. useDimensions: () => ({width: 800}),
  6. }));
  7. describe('MockTimelineVisualizer', () => {
  8. const {organization} = initializeOrg();
  9. it('should request and display mock data', async () => {
  10. const schedule = {
  11. cronSchedule: '0 * * * *',
  12. scheduleType: 'crontab',
  13. };
  14. const data = [
  15. new Date('2023/11/20'),
  16. new Date('2023/11/21'),
  17. new Date('2023/11/22'),
  18. new Date('2023/11/23'),
  19. new Date('2023/11/24'),
  20. new Date('2023/11/25'),
  21. new Date('2023/11/26'),
  22. new Date('2023/11/27'),
  23. new Date('2023/11/28'),
  24. ].map(date => date.getTime() / 1000);
  25. const request = MockApiClient.addMockResponse({
  26. url: `/organizations/${organization.slug}/monitors-schedule-data/`,
  27. body: data,
  28. });
  29. render(<MockTimelineVisualization schedule={schedule} />);
  30. expect(request).toHaveBeenCalled();
  31. expect(await screen.findByText('Nov 21, 2023')).toBeInTheDocument();
  32. });
  33. });