.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / pretty-format / build / plugins / react_test_component.js
1 'use strict';
2
3 Object.defineProperty(exports, '__esModule', {
4   value: true
5 });
6 exports.test = exports.serialize = undefined;
7
8 var _markup = require('./lib/markup');
9
10 /**
11  * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
12  *
13  * This source code is licensed under the MIT license found in the
14  * LICENSE file in the root directory of this source tree.
15  *
16  *
17  */
18
19 const testSymbol = Symbol.for('react.test.json');
20
21 const getPropKeys = object => {
22   const props = object.props;
23
24   return props
25     ? Object.keys(props)
26         .filter(key => props[key] !== undefined)
27         .sort()
28     : [];
29 };
30
31 const serialize = (exports.serialize = (
32   object,
33   config,
34   indentation,
35   depth,
36   refs,
37   printer
38 ) =>
39   ++depth > config.maxDepth
40     ? (0, _markup.printElementAsLeaf)(object.type, config)
41     : (0, _markup.printElement)(
42         object.type,
43         object.props
44           ? (0, _markup.printProps)(
45               getPropKeys(object),
46               // Despite ternary expression, Flow 0.51.0 found incorrect error:
47               // undefined is incompatible with the expected param type of Object
48               // $FlowFixMe
49               object.props,
50               config,
51               indentation + config.indent,
52               depth,
53               refs,
54               printer
55             )
56           : '',
57         object.children
58           ? (0, _markup.printChildren)(
59               object.children,
60               config,
61               indentation + config.indent,
62               depth,
63               refs,
64               printer
65             )
66           : '',
67         config,
68         indentation
69       ));
70
71 const test = (exports.test = val => val && val.$$typeof === testSymbol);
72
73 exports.default = {serialize: serialize, test: test};