Ensure fp convert works with category modules.

This commit is contained in:
John-David Dalton
2016-02-12 22:49:49 -08:00
parent bf9dcfe89c
commit de0f936e92
2 changed files with 71 additions and 15 deletions

View File

@@ -103,6 +103,40 @@
'rearg': false
};
QUnit.test('should work when given an object', function(assert) {
assert.expect(2);
var array = [1, 2, 3, 4],
lodash = convert({ 'remove': _.remove });
var actual = lodash.remove(function(n) {
return n % 2 == 0;
})(array);
assert.deepEqual(array, [1, 2, 3, 4]);
assert.deepEqual(actual, [1, 3]);
});
QUnit.test('should only add a `placeholder` property if needed', function(assert) {
assert.expect(2);
var methodNames = _.keys(mapping.placeholder),
expected = _.map(methodNames, _.constant(true));
var actual = _.map(methodNames, function(methodName) {
var object = {};
object[methodName] = _[methodName];
var lodash = convert(object);
return methodName in lodash;
});
assert.deepEqual(actual, expected);
var lodash = convert({ 'add': _.add });
assert.notOk('placeholder' in lodash);
});
QUnit.test('should accept an `options` argument', function(assert) {
assert.expect(3);
@@ -203,6 +237,21 @@
assert.deepEqual(actual, [1, 3]);
assert.deepEqual(lodash.remove(), []);
});
QUnit.test('should work when given an object and `options`', function(assert) {
assert.expect(3);
var array = [1, 2, 3, 4],
lodash = convert({ 'remove': _.remove }, allFalseOptions);
var actual = lodash.remove(array, function(n, index) {
return index % 2 == 0;
});
assert.deepEqual(array, [2, 4]);
assert.deepEqual(actual, [1, 3]);
assert.deepEqual(lodash.remove(), []);
});
}());
/*--------------------------------------------------------------------------*/