dateSummary.spec.tsx 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import DateSummary from 'sentry/components/organizations/timeRangeSelector/dateSummary';
  3. const start = new Date('2017-10-14T02:38:00.000Z');
  4. const end = new Date('2017-10-17T02:38:00.000Z'); // National Pasta Day
  5. describe('DateSummary', () => {
  6. it('renders', () => {
  7. const {container} = render(<DateSummary start={start} end={end} />);
  8. expect(container).toSnapshot();
  9. });
  10. it('does not show times when it is midnight for start date and 23:59:59 for end date', () => {
  11. const {rerender} = render(<DateSummary start={start} end={end} />);
  12. // Search by year because day may change depending on timezone
  13. expect(screen.getAllByText(/Oct.+2017/)[0].childElementCount).toBe(1);
  14. // Date Summary formats using system time
  15. // tests run on EST/EDT
  16. rerender(
  17. <DateSummary
  18. start={new Date('2017-10-14T00:00:00.000-0400')}
  19. end={new Date('2017-10-17T23:59:59.000-0400')}
  20. />
  21. );
  22. expect(screen.getAllByText(/Oct.+2017/)[0].childElementCount).toBe(0);
  23. });
  24. });