hotkeysLabel.spec.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import HotkeysLabel from 'sentry/components/hotkeysLabel';
  3. describe('HotkeysLabel', function () {
  4. it('ctrl+alt+delete mac', function () {
  5. render(<HotkeysLabel value={['ctrl+alt+delete']} forcePlatform="macos" />);
  6. expect(screen.getByText('⌃')).toBeInTheDocument();
  7. expect(screen.getByText('⌥')).toBeInTheDocument();
  8. expect(screen.getByText('DELETE')).toBeInTheDocument();
  9. });
  10. it('ctrl+alt+delete windows', function () {
  11. render(<HotkeysLabel value={['ctrl+alt+delete']} forcePlatform="generic" />);
  12. expect(screen.getByText('CTRL')).toBeInTheDocument();
  13. expect(screen.getByText('ALT')).toBeInTheDocument();
  14. expect(screen.getByText('DELETE')).toBeInTheDocument();
  15. });
  16. it('falls back when not on mac', function () {
  17. render(<HotkeysLabel value={['cmd', 'alt']} forcePlatform="generic" />);
  18. expect(screen.queryByText('⌘')).not.toBeInTheDocument();
  19. expect(screen.queryByText('CMD')).not.toBeInTheDocument();
  20. expect(screen.getByText('ALT')).toBeInTheDocument();
  21. });
  22. it('does not render at all without fallback', function () {
  23. render(<HotkeysLabel value={['cmd+k', 'cmd+alt+l']} forcePlatform="generic" />);
  24. expect(screen.queryByText('⌘')).not.toBeInTheDocument();
  25. expect(screen.queryByText('L')).not.toBeInTheDocument();
  26. expect(screen.queryByText('ALT')).not.toBeInTheDocument();
  27. });
  28. it('takes just a string', function () {
  29. render(<HotkeysLabel value="option" forcePlatform="generic" />);
  30. expect(screen.getByText('ALT')).toBeInTheDocument();
  31. });
  32. });