mirror of
https://github.com/FormidableLabs/react-fast-compare.git
synced 2026-01-18 16:13:59 +00:00
- Update library to include ES.next support for `Map`, `Set`, `ArrayBuffer`. Part of #36 - Update to `fast-deep-equal@3.1.1` with modified support for ES.next data types. - Upgrade lots of `devDependenices` - Use `fast-deep-equal` tests directly in our correctness tests. - Update CI to modern Node.js versions. - **Note**: There's a bug / limitation of `Set` comparisons whereby objects are compared by reference not value. Tracked at #50 . In our `yarn benchmark`, `lodash.isEqual` gets test differences because it correctly handles those.
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
var assert = require('assert');
|
|
var sinon = require('sinon');
|
|
|
|
var equal = require('../..');
|
|
|
|
const element1 = document.createElement('div');
|
|
const element2 = document.createElement('div');
|
|
const element3 = document.createElement('input');
|
|
|
|
const suites = [{
|
|
description: 'DOM elements',
|
|
tests: [
|
|
{
|
|
description: 'equal DOM elements',
|
|
value1: element1,
|
|
value2: element1,
|
|
equal: true
|
|
},
|
|
{
|
|
description: 'comparison of different elements',
|
|
value1: element1,
|
|
value2: element2,
|
|
equal: false
|
|
},
|
|
{
|
|
description: 'comparison of elements with different types',
|
|
value1: element1,
|
|
value2: element3,
|
|
equal: false
|
|
},
|
|
]
|
|
}];
|
|
|
|
describe('browser', function () {
|
|
let sandbox;
|
|
|
|
beforeEach(() => {
|
|
sandbox = sinon.createSandbox();
|
|
sandbox.stub(console, 'warn');
|
|
});
|
|
|
|
afterEach(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
suites.forEach(function (suite) {
|
|
describe(suite.description, function () {
|
|
suite.tests.forEach(function (test) {
|
|
(test.skip ? it.skip : it)(test.description, function () {
|
|
assert.strictEqual(equal(test.value1, test.value2), test.equal);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|