Ensure curryN, curryRightN, curryRight, and sampleSize are defined.

This commit is contained in:
Benjamin Tan
2015-12-16 13:19:38 +08:00
committed by John-David Dalton
parent e3c79bd24a
commit 44c697908b
2 changed files with 43 additions and 3 deletions

View File

@@ -73,11 +73,11 @@ module.exports = {
/** Used to map ary to method names. */
'aryMethodMap': {
1: (
'attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,' +
'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,overEvery,' +
'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,' +
'trim,trimLeft,trimRight,uniqueId,words').split(','),
2: (
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' +
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,curryRightN,' +
'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' +
'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' +
'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' +
@@ -120,7 +120,8 @@ module.exports = {
'keyMap': {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
'getOr': 'get',
'sampleSize': 'sample'
},
/** Used to identify methods which mutate arrays or objects. */

View File

@@ -321,6 +321,45 @@
var actual = fp.curryN(1, function(a, b) { return [a, b]; })('a');
assert.deepEqual(actual, ['a', undefined]);
});
QUnit.test('should only pass in `arity` number of arguments', function(assert) {
assert.expect(1);
var actual = fp.curryN(1, function(a, b) { return [a, b]; })('a', 'b');
assert.deepEqual(actual, ['a', undefined]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('fp.curryRight');
(function() {
QUnit.test('should accept only a `func` param', function(assert) {
assert.expect(1);
assert.raises(function() { fp.curryRight(1, _.noop); }, TypeError);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('fp.curryRightN');
(function() {
QUnit.test('should accept an `arity` param', function(assert) {
assert.expect(1);
var actual = fp.curryRightN(1, function(a, b) { return [a, b]; })('a');
assert.deepEqual(actual, ['a', undefined]);
});
QUnit.test('should only pass in `arity` number of arguments', function(assert) {
assert.expect(1);
var actual = fp.curryRightN(1, function(a, b) { return [a, b]; })('a', 'b');
assert.deepEqual(actual, ['a', undefined]);
});
}());
/*--------------------------------------------------------------------------*/