featureBadge.spec.tsx 931 B

123456789101112131415161718192021222324252627282930
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import FeatureBadge from 'sentry/components/featureBadge';
  3. describe('FeatureBadge', function () {
  4. it('auto-hides when expired', function () {
  5. const {rerender} = render(
  6. <FeatureBadge
  7. type="new"
  8. title="Something awesome"
  9. expiresAt={new Date(2018, 9, 16)}
  10. />
  11. );
  12. expect(screen.getByText('new')).toBeInTheDocument();
  13. rerender(
  14. <FeatureBadge
  15. type="new"
  16. title="Something awesome"
  17. expiresAt={new Date(2017, 9, 16)}
  18. />
  19. );
  20. expect(screen.queryByText('new')).not.toBeInTheDocument();
  21. });
  22. it('shows before expiry date', function () {
  23. // One hour from 'now'.
  24. const expires = new Date(Date.now() + 1000 * 60 * 60);
  25. render(<FeatureBadge type="new" title="Something awesome" expiresAt={expires} />);
  26. expect(screen.getByText('new')).toBeInTheDocument();
  27. });
  28. });