mirror of
https://github.com/FormidableLabs/react-fast-compare.git
synced 2026-01-18 16:13:59 +00:00
Up to date with fast-deep-equal@2.0.1. * null and object comparison * new behavior: different functions that are not equal * new behavior: handle NaN * Add tests from fast-deep-equal@2.0.1 * Move tests from fast-deep-equal@2.0.1 to separate file * Add comments to identify fast-deep-equal code * Add comments to identify custom handling for React
69 lines
1.4 KiB
JavaScript
69 lines
1.4 KiB
JavaScript
'use strict';
|
|
var generic = require('./fast-deep-equal-tests.js');
|
|
|
|
const reactElementA = {
|
|
'$$typeof': 'react.element',
|
|
type: 'div',
|
|
key: null,
|
|
ref: null,
|
|
props: { x: 1 },
|
|
_owner: {},
|
|
_store: {}
|
|
};
|
|
// in reality the _owner object is much more complex (and contains over dozen circular references)
|
|
reactElementA._owner.children = [reactElementA];
|
|
|
|
const reactElementA2 = {
|
|
'$$typeof': 'react.element',
|
|
type: 'div',
|
|
key: null,
|
|
ref: null,
|
|
props: { x: 1 },
|
|
_owner: {},
|
|
_store: {}
|
|
};
|
|
reactElementA2._owner.children = [reactElementA2];
|
|
|
|
const reactElementB = {
|
|
'$$typeof': 'react.element',
|
|
type: 'div',
|
|
key: null,
|
|
ref: null,
|
|
props: { x: 2 },
|
|
_owner: {},
|
|
_store: {}
|
|
};
|
|
reactElementB._owner.children = [reactElementB];
|
|
|
|
const react = [
|
|
{
|
|
description: 'React elements',
|
|
reactSpecific: true,
|
|
tests: [
|
|
{
|
|
description: 'an element compared with itself',
|
|
value1: reactElementA,
|
|
value2: reactElementA,
|
|
equal: true
|
|
},
|
|
{
|
|
description: 'two elements equal by value',
|
|
value1: reactElementA,
|
|
value2: reactElementA2,
|
|
equal: true
|
|
},
|
|
{
|
|
description: 'two elements unequal by value',
|
|
value1: reactElementA,
|
|
value2: reactElementB,
|
|
equal: false
|
|
}
|
|
]
|
|
}
|
|
];
|
|
|
|
module.exports = {
|
|
generic,
|
|
react,
|
|
all: [].concat(generic, react)
|
|
}; |