mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Move this binding tests around.
This commit is contained in:
38
test/test.js
38
test/test.js
@@ -10274,16 +10274,6 @@
|
|||||||
strictEqual(memoized(1, 3, 5), 9);
|
strictEqual(memoized(1, 3, 5), 9);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not set a `this` binding', 2, function() {
|
|
||||||
var memoized = _.memoize(function(a, b, c) {
|
|
||||||
return a + this.b + this.c;
|
|
||||||
});
|
|
||||||
|
|
||||||
var object = { 'b': 2, 'c': 3, 'memoized': memoized };
|
|
||||||
strictEqual(object.memoized(1), 6);
|
|
||||||
strictEqual(object.memoized(2), 7);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should throw a TypeError if `resolve` is truthy and not a function', function() {
|
test('should throw a TypeError if `resolve` is truthy and not a function', function() {
|
||||||
raises(function() { _.memoize(_.noop, {}); }, TypeError);
|
raises(function() { _.memoize(_.noop, {}); }, TypeError);
|
||||||
});
|
});
|
||||||
@@ -10300,6 +10290,16 @@
|
|||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not set a `this` binding', 2, function() {
|
||||||
|
var memoized = _.memoize(function(a, b, c) {
|
||||||
|
return a + this.b + this.c;
|
||||||
|
});
|
||||||
|
|
||||||
|
var object = { 'b': 2, 'c': 3, 'memoized': memoized };
|
||||||
|
strictEqual(object.memoized(1), 6);
|
||||||
|
strictEqual(object.memoized(2), 7);
|
||||||
|
});
|
||||||
|
|
||||||
test('should check cache for own properties', 1, function() {
|
test('should check cache for own properties', 1, function() {
|
||||||
var memoized = _.memoize(_.identity);
|
var memoized = _.memoize(_.identity);
|
||||||
|
|
||||||
@@ -16809,15 +16809,6 @@
|
|||||||
deepEqual(args, [_.noop, 1, 2, 3]);
|
deepEqual(args, [_.noop, 1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not set a `this` binding', 1, function() {
|
|
||||||
var p = _.wrap(_.escape, function(func) {
|
|
||||||
return '<p>' + func(this.text) + '</p>';
|
|
||||||
});
|
|
||||||
|
|
||||||
var object = { 'p': p, 'text': 'fred, barney, & pebbles' };
|
|
||||||
strictEqual(object.p(), '<p>fred, barney, & pebbles</p>');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should use `_.identity` when `wrapper` is nullish', 1, function() {
|
test('should use `_.identity` when `wrapper` is nullish', 1, function() {
|
||||||
var values = [, null, undefined],
|
var values = [, null, undefined],
|
||||||
expected = _.map(values, _.constant('a'));
|
expected = _.map(values, _.constant('a'));
|
||||||
@@ -16829,6 +16820,15 @@
|
|||||||
|
|
||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not set a `this` binding', 1, function() {
|
||||||
|
var p = _.wrap(_.escape, function(func) {
|
||||||
|
return '<p>' + func(this.text) + '</p>';
|
||||||
|
});
|
||||||
|
|
||||||
|
var object = { 'p': p, 'text': 'fred, barney, & pebbles' };
|
||||||
|
strictEqual(object.p(), '<p>fred, barney, & pebbles</p>');
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user