raf.js 528 B

1234567891011121314151617181920
  1. import { requestAnimationFrame, cancelAnimationFrame } from 'scroll/util/raf'
  2. describe('raf.js', () => {
  3. it('#requestAnimationFrame() & #cancelAnimationFrame()', () => {
  4. const fn = sinon.spy()
  5. let id = requestAnimationFrame(fn)
  6. return new Promise((resolve) => {
  7. setTimeout(() => {
  8. expect(fn)
  9. .to.be.calledOnce
  10. cancelAnimationFrame(id)
  11. setTimeout(() => {
  12. expect(fn)
  13. .not.to.be.calledTwice
  14. resolve()
  15. }, 20)
  16. }, 20)
  17. })
  18. })
  19. })