mockTimelineVisualization.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 22, 2023')).toBeInTheDocument();
  32. expect(await screen.findByText('Nov 24, 2023')).toBeInTheDocument();
  33. expect(await screen.findByText('Nov 26, 2023')).toBeInTheDocument();
  34. });
  35. });