mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Rearrange tests for consistency.
This commit is contained in:
102
test/test.js
102
test/test.js
@@ -2802,7 +2802,7 @@
|
|||||||
assert.deepEqual(actual, [objects[1]]);
|
assert.deepEqual(actual, [objects[1]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should match properties when `object` is not a plain object', function(assert) {
|
QUnit.test('should work with a non-plain `object`', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
function Foo() {
|
function Foo() {
|
||||||
@@ -8978,6 +8978,15 @@
|
|||||||
assert.deepEqual(actual, [false, true]);
|
assert.deepEqual(actual, [false, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with a non-plain `object`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
function Foo(object) { lodashStable.assign(this, object); }
|
||||||
|
|
||||||
|
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) });
|
||||||
|
assert.strictEqual(_.isMatch(object, { 'a': { 'b': 1 } }), true);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should partial match arrays', function(assert) {
|
QUnit.test('should partial match arrays', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -9081,15 +9090,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should match properties when `object` is not a plain object', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
function Foo(object) { lodashStable.assign(this, object); }
|
|
||||||
|
|
||||||
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) });
|
|
||||||
assert.strictEqual(_.isMatch(object, { 'a': { 'b': 1 } }), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should match `undefined` values', function(assert) {
|
QUnit.test('should match `undefined` values', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -11784,6 +11784,17 @@
|
|||||||
assert.deepEqual(actual, [false, true]);
|
assert.deepEqual(actual, [false, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with a non-plain `object`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
function Foo(object) { lodashStable.assign(this, object); }
|
||||||
|
|
||||||
|
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }),
|
||||||
|
matches = _.matches({ 'a': { 'b': 1 } });
|
||||||
|
|
||||||
|
assert.strictEqual(matches(object), true);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should partial match arrays', function(assert) {
|
QUnit.test('should partial match arrays', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -11871,17 +11882,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should match properties when `object` is not a plain object', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
function Foo(object) { lodashStable.assign(this, object); }
|
|
||||||
|
|
||||||
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }),
|
|
||||||
matches = _.matches({ 'a': { 'b': 1 } });
|
|
||||||
|
|
||||||
assert.strictEqual(matches(object), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should match `undefined` values', function(assert) {
|
QUnit.test('should match `undefined` values', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -12207,6 +12207,17 @@
|
|||||||
assert.deepEqual(actual, [false, true]);
|
assert.deepEqual(actual, [false, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with a non-plain `srcValue`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
function Foo(object) { lodashStable.assign(this, object); }
|
||||||
|
|
||||||
|
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }),
|
||||||
|
matches = _.matchesProperty('a', { 'b': 1 });
|
||||||
|
|
||||||
|
assert.strictEqual(matches(object), true);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should partial match arrays', function(assert) {
|
QUnit.test('should partial match arrays', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -12293,17 +12304,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should match properties when `srcValue` is not a plain object', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
function Foo(object) { lodashStable.assign(this, object); }
|
|
||||||
|
|
||||||
var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }),
|
|
||||||
matches = _.matchesProperty('a', { 'b': 1 });
|
|
||||||
|
|
||||||
assert.strictEqual(matches(object), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should match `undefined` values', function(assert) {
|
QUnit.test('should match `undefined` values', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
@@ -12319,25 +12319,6 @@
|
|||||||
assert.deepEqual(actual, expected);
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return `false` when `object` is nullish', function(assert) {
|
|
||||||
assert.expect(2);
|
|
||||||
|
|
||||||
var values = [, null, undefined],
|
|
||||||
expected = lodashStable.map(values, lodashStable.constant(false));
|
|
||||||
|
|
||||||
lodashStable.each(['constructor', ['constructor']], function(path) {
|
|
||||||
var matches = _.matchesProperty(path, 1);
|
|
||||||
|
|
||||||
var actual = lodashStable.map(values, function(value, index) {
|
|
||||||
try {
|
|
||||||
return index ? matches(value) : matches();
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should match `undefined` values on primitives', function(assert) {
|
QUnit.test('should match `undefined` values on primitives', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
@@ -12361,6 +12342,25 @@
|
|||||||
delete numberProto.b;
|
delete numberProto.b;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should return `false` when `object` is nullish', function(assert) {
|
||||||
|
assert.expect(2);
|
||||||
|
|
||||||
|
var values = [, null, undefined],
|
||||||
|
expected = lodashStable.map(values, lodashStable.constant(false));
|
||||||
|
|
||||||
|
lodashStable.each(['constructor', ['constructor']], function(path) {
|
||||||
|
var matches = _.matchesProperty(path, 1);
|
||||||
|
|
||||||
|
var actual = lodashStable.map(values, function(value, index) {
|
||||||
|
try {
|
||||||
|
return index ? matches(value) : matches();
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should return `true` when comparing a `srcValue` of empty arrays and objects', function(assert) {
|
QUnit.test('should return `true` when comparing a `srcValue` of empty arrays and objects', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user