hotkeys.test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Icon, Dropdown, Tag, HotKeys } from '../../index';
  2. import { string } from 'prop-types';
  3. import { noop, drop } from 'lodash';
  4. import { BASE_CLASS_PREFIX } from '../../../semi-foundation/base/constants';
  5. import {sleep} from "../../_test_/utils";
  6. function getHK(props) {
  7. return mount(<HotKeys {...props}></HotKeys>, {
  8. attachTo: document.getElementById('container'),
  9. });
  10. }
  11. describe('HotKeys', () => {
  12. beforeEach(() => {
  13. document.body.innerHTML = '';
  14. // Avoid `attachTo: document.body` Warning
  15. const div = document.createElement('div');
  16. div.setAttribute('id', 'container');
  17. document.body.appendChild(div);
  18. });
  19. afterEach(() => {
  20. const div = document.getElementById('container');
  21. if (div) {
  22. document.body.removeChild(div);
  23. }
  24. });
  25. it('HotKeys-custom className & style', () => {
  26. let props = {
  27. className: 'test',
  28. style: {
  29. color: 'red',
  30. },
  31. hotKeys: ['r']
  32. };
  33. const hotkeys = getHK(props);
  34. expect(hotkeys.exists(`.${BASE_CLASS_PREFIX}-hotKeys.test`)).toEqual(true);
  35. expect(hotkeys.find(`.${BASE_CLASS_PREFIX}-hotKeys`)).toHaveStyle('color', 'red');
  36. });
  37. });