aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/withinRange.test.js
blob: baec1222b2ad01073f8b806fabb6febbfa014151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import withinRange from './withinRange';

describe('withinRange', () => {
  describe('the number is within range', () => {
    it('just returns the number', () => {
      expect(withinRange(5, 7)).toEqual(5);
    });
  });

  describe('the number is outside the range', () => {
    it('wraps the number until within range', () => {
      expect(withinRange(-1, 6)).toEqual(6);
      expect(withinRange(7, 6)).toEqual(0);
      expect(withinRange(-20, 6)).toEqual(1);
      expect(withinRange(20, 6)).toEqual(6);
    });
  });
});