react_test_component.js 1.2 KB

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