123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', {
- value: true
- });
- exports.test = exports.serialize = undefined;
- var _collections = require('../collections');
- /**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
- const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');
- const SPACE = ' ';
- const serialize = (exports.serialize = (
- val,
- config,
- indentation,
- depth,
- refs,
- printer
- ) => {
- const stringedValue = val.toString();
- if (
- stringedValue === 'ArrayContaining' ||
- stringedValue === 'ArrayNotContaining'
- ) {
- if (++depth > config.maxDepth) {
- return '[' + stringedValue + ']';
- }
- return (
- stringedValue +
- SPACE +
- '[' +
- (0, _collections.printListItems)(
- val.sample,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']'
- );
- }
- if (
- stringedValue === 'ObjectContaining' ||
- stringedValue === 'ObjectNotContaining'
- ) {
- if (++depth > config.maxDepth) {
- return '[' + stringedValue + ']';
- }
- return (
- stringedValue +
- SPACE +
- '{' +
- (0, _collections.printObjectProperties)(
- val.sample,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}'
- );
- }
- if (
- stringedValue === 'StringMatching' ||
- stringedValue === 'StringNotMatching'
- ) {
- return (
- stringedValue +
- SPACE +
- printer(val.sample, config, indentation, depth, refs)
- );
- }
- if (
- stringedValue === 'StringContaining' ||
- stringedValue === 'StringNotContaining'
- ) {
- return (
- stringedValue +
- SPACE +
- printer(val.sample, config, indentation, depth, refs)
- );
- }
- return val.toAsymmetricMatcher();
- });
- const test = (exports.test = val => val && val.$$typeof === asymmetricMatcher);
- exports.default = {serialize: serialize, test: test};
|