mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Add _.cond test for shorthands.
This commit is contained in:
14
test/test.js
14
test/test.js
@@ -2788,6 +2788,20 @@
|
|||||||
assert.raises(function() { _.cond([[predicate, value]]); }, TypeError);
|
assert.raises(function() { _.cond([[predicate, value]]); }, TypeError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with predicate shorthands', function(assert) {
|
||||||
|
assert.expect(3);
|
||||||
|
|
||||||
|
var cond = _.cond([
|
||||||
|
[{ 'a': 1 }, lodashStable.constant('A')],
|
||||||
|
[['b', 1], lodashStable.constant('B')],
|
||||||
|
['c', lodashStable.constant('C')]
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.strictEqual(cond({ 'a': 1, 'b': 2, 'c': 3 }), 'A');
|
||||||
|
assert.strictEqual(cond({ 'a': 0, 'b': 1, 'c': 2 }), 'B');
|
||||||
|
assert.strictEqual(cond({ 'a': -1, 'b': 0, 'c': 1 }), 'C');
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user