react_test_component.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.serialize = undefined;
  2. var _markup = require('./lib/markup'); /**
  3. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. *
  8. *
  9. */const testSymbol = Symbol.for('react.test.json');
  10. const serialize = exports.serialize = (
  11. object,
  12. config,
  13. indentation,
  14. depth,
  15. refs,
  16. printer) =>
  17. ++depth > config.maxDepth ?
  18. (0, _markup.printElementAsLeaf)(object.type, config) :
  19. (0, _markup.printElement)(
  20. object.type,
  21. object.props ?
  22. (0, _markup.printProps)(
  23. Object.keys(object.props).sort(),
  24. // Despite ternary expression, Flow 0.51.0 found incorrect error:
  25. // undefined is incompatible with the expected param type of Object
  26. // $FlowFixMe
  27. object.props,
  28. config,
  29. indentation + config.indent,
  30. depth,
  31. refs,
  32. printer) :
  33. '',
  34. object.children ?
  35. (0, _markup.printChildren)(
  36. object.children,
  37. config,
  38. indentation + config.indent,
  39. depth,
  40. refs,
  41. printer) :
  42. '',
  43. config,
  44. indentation);
  45. const test = exports.test = val => val && val.$$typeof === testSymbol;exports.default =
  46. { serialize, test };