license import { after , before , } from 'mocha-sugar-free' ; import { SinonStub , stub , } from 'sinon' ; import { Performance , } from './Performance' ; export type PerformanceClosure = ( performance : Performance ) => any ; /**
 * Replaces window.requestAnimationFrame with a mock for the duration of a mocha
 * testing suite.
 */ export default function useMockedPerformance ( closure ) { return ( ) => { const mockPerformance = new Performance ( ) ; before ( ( ) => { stub ( performance , 'now' ) . callsFake ( mockPerformance . now ) ; } ) ; after ( ( ) => { ( performance . now as SinonStub ) . restore ( ) ; } ) ; return closure ( mockPerformance ) ; } ; } ;