mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Make min optional for _.clamp.
This commit is contained in:
33
test/test.js
33
test/test.js
@@ -2055,7 +2055,7 @@
|
||||
assert.strictEqual(_.clamp(-5.5, -5.6, 5.6), -5.5);
|
||||
});
|
||||
|
||||
QUnit.test('should not alter positive numbers in range`', function(assert) {
|
||||
QUnit.test('should not alter positive numbers in range', function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
assert.strictEqual(_.clamp(4, -5, 5), 4);
|
||||
@@ -2063,38 +2063,41 @@
|
||||
assert.strictEqual(_.clamp(4.5, -5.1, 5.2), 4.5);
|
||||
});
|
||||
|
||||
QUnit.test('should not alter positive zero in range', function(assert) {
|
||||
QUnit.test('should not alter `0` in range', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(1 / _.clamp(0, -5, 5), 1 / 0);
|
||||
assert.strictEqual(1 / _.clamp(0, -5, 5), Infinity);
|
||||
});
|
||||
|
||||
QUnit.test('should clamp to positive zero', function(assert) {
|
||||
QUnit.test('should clamp to `0`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(1 / _.clamp(-10, 0, 5), 1 / 0);
|
||||
assert.strictEqual(1 / _.clamp(-10, 0, 5), Infinity);
|
||||
});
|
||||
|
||||
QUnit.test('should not alter negative zero in range', function(assert) {
|
||||
QUnit.test('should not alter `-0` in range', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(1 / _.clamp(-0, -5, 5), 1 / -0);
|
||||
assert.strictEqual(1 / _.clamp(-0, -5, 5), -Infinity);
|
||||
});
|
||||
|
||||
QUnit.test('should clamp to negative zero', function(assert) {
|
||||
QUnit.test('should clamp to `-0`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(1 / _.clamp(-10, -0, 5), 1 / -0);
|
||||
assert.strictEqual(1 / _.clamp(-10, -0, 5), -Infinity);
|
||||
});
|
||||
|
||||
QUnit.test('should return NaN if an argument is or is coerced to NaN', function(assert) {
|
||||
assert.expect(5);
|
||||
QUnit.test('should return `NaN` when `number` is `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.deepEqual(_.clamp(NaN, -5, 5), NaN);
|
||||
assert.deepEqual(_.clamp(Infinity, -5, NaN), NaN);
|
||||
assert.deepEqual(_.clamp(-Infinity, -5, NaN), NaN);
|
||||
assert.deepEqual(_.clamp(Infinity, NaN, 5), NaN);
|
||||
assert.deepEqual(_.clamp(-Infinity, NaN, 5), NaN);
|
||||
});
|
||||
|
||||
QUnit.test('should coerce `min` and `max` of `NaN` to `0`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
assert.deepEqual(_.clamp(1, -5, NaN), 0);
|
||||
assert.deepEqual(_.clamp(-1, NaN, 5), 0);
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user