useViewRange.test.ts 957 B

1234567891011121314151617181920212223242526
  1. import { renderHook, act } from '@testing-library/react-hooks';
  2. import { useViewRange } from './useViewRange';
  3. describe('useViewRange', () => {
  4. it('defaults to full range', async () => {
  5. const { result } = renderHook(() => useViewRange());
  6. expect(result.current.viewRange).toEqual({ time: { current: [0, 1] } });
  7. });
  8. describe('updateNextViewRangeTime', () => {
  9. it('updates time', async () => {
  10. const { result } = renderHook(() => useViewRange());
  11. act(() => result.current.updateNextViewRangeTime({ cursor: 0.5 }));
  12. expect(result.current.viewRange).toEqual({ time: { current: [0, 1], cursor: 0.5 } });
  13. });
  14. });
  15. describe('updateViewRangeTime', () => {
  16. it('updates time', async () => {
  17. const { result } = renderHook(() => useViewRange());
  18. act(() => result.current.updateViewRangeTime(0.1, 0.2));
  19. expect(result.current.viewRange).toEqual({ time: { current: [0.1, 0.2] } });
  20. });
  21. });
  22. });