mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Add placeholder tests to for _.bindKey.
This commit is contained in:
27
test/test.js
27
test/test.js
@@ -978,17 +978,36 @@
|
|||||||
var object = {
|
var object = {
|
||||||
'name': 'fred',
|
'name': 'fred',
|
||||||
'greet': function(greeting) {
|
'greet': function(greeting) {
|
||||||
return greeting + ' ' + this.name;
|
return this.name + ' says: ' + greeting;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var bound = _.bindKey(object, 'greet', 'hi');
|
var bound = _.bindKey(object, 'greet', 'hi');
|
||||||
equal(bound(), 'hi fred');
|
equal(bound(), 'fred says: hi');
|
||||||
|
|
||||||
object.greet = function(greeting) {
|
object.greet = function(greeting) {
|
||||||
return greeting + ' ' + this.name + '!';
|
return this.name + ' says: ' + greeting + '!';
|
||||||
};
|
};
|
||||||
equal(bound(), 'hi fred!');
|
equal(bound(), 'fred says: hi!');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should support placeholders', 4, function() {
|
||||||
|
var object = {
|
||||||
|
'fn': function fn(a, b, c, d) {
|
||||||
|
return slice.call(arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isPreBuild) {
|
||||||
|
var bound = _.bindKey(object, 'fn', _, 'b', _);
|
||||||
|
deepEqual(bound('a', 'c'), ['a', 'b', 'c']);
|
||||||
|
deepEqual(bound('a'), ['a', 'b', undefined]);
|
||||||
|
deepEqual(bound('a', 'c', 'd'), ['a', 'b', 'c', 'd']);
|
||||||
|
deepEqual(bound(), [undefined, 'b', undefined]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(4);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user