ReactTestComponent.js
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.serialize = void 0;
var _markup = require('./lib/markup');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const testSymbol =
typeof Symbol === 'function' && Symbol.for
? Symbol.for('react.test.json')
: 0xea71357;
const getPropKeys = object => {
const {props} = object;
return props
? Object.keys(props)
.filter(key => props[key] !== undefined)
.sort()
: [];
};
const 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)(
getPropKeys(object),
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
);
exports.serialize = serialize;
const test = val => val && val.$$typeof === testSymbol;
exports.test = test;
const plugin = {
serialize,
test
};
var _default = plugin;
exports.default = _default;