bump jest and make tests pass

This commit is contained in:
Louis Hache
2020-11-13 19:11:55 +01:00
parent d28dc26fa3
commit 4f58d166b7
5769 changed files with 856618 additions and 394571 deletions
+17 -40
View File
@@ -7,38 +7,14 @@ exports.default = exports.serialize = exports.test = void 0;
var _collections = require('../collections');
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. 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.
*/
/* eslint-disable local/ban-types-eventually */
const SPACE = ' ';
const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
@@ -49,15 +25,13 @@ const testName = name =>
const test = val =>
val &&
val.constructor &&
val.constructor.name &&
testName(val.constructor.name); // Convert array of attribute objects to props object.
!!val.constructor.name &&
testName(val.constructor.name);
exports.test = test;
const propsReducer = (props, attribute) => {
props[attribute.name] = attribute.value;
return props;
};
const isNamedNodeMap = collection =>
collection.constructor.name === 'NamedNodeMap';
const serialize = (collection, config, indentation, depth, refs, printer) => {
const name = collection.constructor.name;
@@ -71,9 +45,12 @@ const serialize = (collection, config, indentation, depth, refs, printer) => {
(OBJECT_NAMES.indexOf(name) !== -1
? '{' +
(0, _collections.printObjectProperties)(
name === 'NamedNodeMap'
? Array.prototype.reduce.call(collection, propsReducer, {})
: _objectSpread({}, collection),
isNamedNodeMap(collection)
? Array.from(collection).reduce((props, attribute) => {
props[attribute.name] = attribute.value;
return props;
}, {})
: {...collection},
config,
indentation,
depth,