Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

50 строки
1.2 KiB

  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow
  8. * @format
  9. * @emails oncall+draft_js
  10. */
  11. const BLACK_LIST_PROPS = ['data-reactroot'];
  12. const transformSnapshotProps = (node: any, blackList: Array<string> = BLACK_LIST_PROPS): any => {
  13. const stack = [node];
  14. while (stack.length) {
  15. const node = stack.pop();
  16. if (node.props) {
  17. if (node.props.className) {
  18. node.props.className = node.props.className.replace(/-/g, '__');
  19. }
  20. BLACK_LIST_PROPS.forEach(prop => delete node.props[prop]);
  21. }
  22. if (Array.isArray(node.children)) {
  23. stack.push(...node.children);
  24. }
  25. }
  26. return node;
  27. };
  28. const DraftTestHelper = {
  29. /**
  30. * This is meant to be used in combination with ReactTestRenderer
  31. * to ensure compatibility with running our snapshot tests internally
  32. *
  33. * usage example:
  34. *
  35. * const blockNode = ReactTestRenderer.create(
  36. * <DraftComponentFooBar {...childProps} />,
  37. * );
  38. *
  39. * expect(transformSnapshotProps(blockNode.toJSON())).toMatchSnapshot();
  40. */
  41. transformSnapshotProps
  42. };
  43. module.exports = DraftTestHelper;