mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add _.matches test and cleanup _.property and _.constant tests.
This commit is contained in:
34
test/test.js
34
test/test.js
@@ -5242,15 +5242,21 @@
|
|||||||
QUnit.module('lodash.matches');
|
QUnit.module('lodash.matches');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
test('should create a function that performs a deep comparison between a given object and the `props` object', 3, function() {
|
var object = { 'a': 1, 'b': 2 };
|
||||||
var object = { 'a': 1, 'b': 2 },
|
|
||||||
actual = _.matches({ 'a': 1 });
|
|
||||||
|
|
||||||
equal(actual.length, 1);
|
test('should create a function that performs a deep comparison between a given object and the `source` object', 3, function() {
|
||||||
strictEqual(actual(object), true);
|
var matches = _.matches({ 'a': 1 });
|
||||||
|
|
||||||
actual = _.matches({ 'b': 1 });
|
equal(matches.length, 1);
|
||||||
strictEqual(actual(object), false);
|
strictEqual(matches(object), true);
|
||||||
|
|
||||||
|
matches = _.matches({ 'b': 1 });
|
||||||
|
strictEqual(matches(object), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return `false` when comparing an empty `source`', 1, function() {
|
||||||
|
var matches = _.matches({});
|
||||||
|
strictEqual(matches(object), false);
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -6251,20 +6257,20 @@
|
|||||||
(function() {
|
(function() {
|
||||||
test('should create a function that plucks a property value of a given object', 3, function() {
|
test('should create a function that plucks a property value of a given object', 3, function() {
|
||||||
var object = { 'a': 1, 'b': 2 },
|
var object = { 'a': 1, 'b': 2 },
|
||||||
actual = _.property('a');
|
property = _.property('a');
|
||||||
|
|
||||||
equal(actual.length, 1);
|
equal(property.length, 1);
|
||||||
strictEqual(actual(object), 1);
|
strictEqual(property(object), 1);
|
||||||
|
|
||||||
actual = _.property('b');
|
property = _.property('b');
|
||||||
strictEqual(actual(object), 2);
|
strictEqual(property(object), 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with non-string `prop` arguments', 1, function() {
|
test('should work with non-string `prop` arguments', 1, function() {
|
||||||
var array = [1, 2, 3],
|
var array = [1, 2, 3],
|
||||||
actual = _.property(1);
|
property = _.property(1);
|
||||||
|
|
||||||
equal(actual(array), 2);
|
equal(property(array), 2);
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user