apphouse
Version:
Component library for React that uses observable state management and theme-able components.
26 lines (21 loc) • 827 B
text/typescript
import { inRange } from './inRange';
describe('inRange', () => {
test('should return true if number is within the specified range', () => {
expect(inRange(5, 1, 10)).toBe(true);
expect(inRange(-3, -5, 0)).toBe(true);
expect(inRange(0, -5, 5)).toBe(true);
});
test('should return false if number is outside the specified range', () => {
expect(inRange(15, 1, 10)).toBe(false);
expect(inRange(-10, 0, 5)).toBe(false);
expect(inRange(5, 6, 10)).toBe(false);
});
test('should assume a range from 0 to start if only one argument is provided', () => {
expect(inRange(5, 10)).toBe(true);
expect(inRange(15, 10)).toBe(false);
});
test('should assume a range from 0 if no arguments are provided', () => {
expect(inRange(5)).toBe(true);
expect(inRange(-5)).toBe(true);
});
});