-
Notifications
You must be signed in to change notification settings - Fork 1
/
fromTo.test.ts
35 lines (30 loc) · 866 Bytes
/
fromTo.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { getDirection, fromTo } from './fromTo';
describe('#getDirection', () => {
it('should positive direction', () => {
expect(getDirection(0, 3)).toBe(1);
expect(getDirection(0, 0)).toBe(1);
});
it('should negative direction', () => {
expect(getDirection(3, 0)).toBe(-1);
});
});
describe('#fromTo', () => {
it('should generate values in the specified range', () => {
const range = fromTo(0, 3);
expect(range()).toBe(0);
expect(range()).toBe(1);
expect(range()).toBe(2);
expect(range()).toBeNull();
});
it('should generate values in single-step range', () => {
const range = fromTo(0, 0);
expect(range()).toBeNull();
});
it('should generate values in an inverse range', () => {
const range = fromTo(3, 0);
expect(range()).toBe(3);
expect(range()).toBe(2);
expect(range()).toBe(1);
expect(range()).toBeNull();
});
});