FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
export default function clamp(value, lower, upper) { throw new Error('Not implemented'); }
import clamp from './clamp'; describe('clamp', () => { test('within range', () => expect(clamp(3, 0, 5)).toBe(3)); test('below lower', () => expect(clamp(-10, -3, 5)).toBe(-3)); test('above upper', () => expect(clamp(10, -5, 5)).toBe(5)); test('on bounds (inclusive)', () => { expect(clamp(0, 0, 5)).toBe(0); expect(clamp(5, 0, 5)).toBe(5); }); });
▶ Run tests
Results
Console
Run tests to see results.