clamp.test.mjs 338 B

123456
  1. import test from 'node:test';
  2. import assert from 'node:assert/strict';
  3. import { clamp } from './clamp.mjs';
  4. test('keeps values inside the range', () => assert.equal(clamp(5, 0, 10), 5));
  5. test('clamps below the minimum', () => assert.equal(clamp(-3, 0, 10), 0));
  6. test('clamps above the maximum', () => assert.equal(clamp(14, 0, 10), 10));