JSXElementMock.js 685 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @flow
  3. */
  4. import JSXAttributeMock from './JSXAttributeMock';
  5. export type TJSXElementMock = {
  6. type: 'JSXElement',
  7. openingElement: {
  8. type: 'JSXOpeningElement',
  9. name: {
  10. type: 'JSXIdentifier',
  11. name: string,
  12. },
  13. attributes: Array<JSXAttributeMock>,
  14. },
  15. children: Array<Node>,
  16. };
  17. export default function JSXElementMock(
  18. tagName: string,
  19. attributes: Array<JSXAttributeMock> = [],
  20. children: Array<Node> = [],
  21. ): TJSXElementMock {
  22. return {
  23. type: 'JSXElement',
  24. openingElement: {
  25. type: 'JSXOpeningElement',
  26. name: {
  27. type: 'JSXIdentifier',
  28. name: tagName,
  29. },
  30. attributes,
  31. },
  32. children,
  33. };
  34. }