()
| 664 | } |
| 665 | |
| 666 | function describeLoopProp() { |
| 667 | describe('the "loop" prop', () => { |
| 668 | it('resets the animation once finished', async () => { |
| 669 | const spring = new SpringValue(0) |
| 670 | spring.start(1, { |
| 671 | loop: true, |
| 672 | config: { duration: frameLength * 3 }, |
| 673 | }) |
| 674 | |
| 675 | await global.advanceUntilValue(spring, 1) |
| 676 | const firstRun = global.getFrames(spring) |
| 677 | expect(firstRun).toMatchSnapshot() |
| 678 | |
| 679 | // The loop resets the value before the next frame. |
| 680 | // FIXME: Reset on next frame instead? |
| 681 | expect(spring.get()).toBe(0) |
| 682 | |
| 683 | await global.advanceUntilValue(spring, 1) |
| 684 | expect(global.getFrames(spring)).toEqual(firstRun) |
| 685 | }) |
| 686 | |
| 687 | it('can pass a custom delay', async () => { |
| 688 | const spring = new SpringValue(0) |
| 689 | spring.start(1, { |
| 690 | loop: { reset: true, delay: 1000 }, |
| 691 | }) |
| 692 | |
| 693 | await global.advanceUntilValue(spring, 1) |
| 694 | expect(spring.get()).toBe(1) |
| 695 | |
| 696 | global.mockRaf.step({ time: 1000 }) |
| 697 | expect(spring.get()).toBeLessThan(1) |
| 698 | |
| 699 | await global.advanceUntilValue(spring, 1) |
| 700 | expect(spring.get()).toBe(1) |
| 701 | }) |
| 702 | |
| 703 | it('supports deferred evaluation', async () => { |
| 704 | const spring = new SpringValue(0) |
| 705 | |
| 706 | let loop: any = true |
| 707 | spring.start(1, { loop: () => loop }) |
| 708 | |
| 709 | await global.advanceUntilValue(spring, 1) |
| 710 | expect(spring.idle).toBeFalsy() |
| 711 | expect(spring.get()).toBeLessThan(1) |
| 712 | |
| 713 | loop = { reset: true, delay: 1000 } |
| 714 | await global.advanceUntilValue(spring, 1) |
| 715 | expect(spring.idle).toBeTruthy() |
| 716 | expect(spring.get()).toBe(1) |
| 717 | |
| 718 | global.mockRaf.step({ time: 1000 }) |
| 719 | expect(spring.idle).toBeFalsy() |
| 720 | expect(spring.get()).toBeLessThan(1) |
| 721 | |
| 722 | loop = false |
| 723 | await global.advanceUntilValue(spring, 1) |
no test coverage detected
searching dependent graphs…