import { memoizeOnce } from "./memoize" ; describe ( "memoizeOnce" , ( ) => { it ( "should not recalculate after initial run" , ( ) => { var x = { Value : 2 } ; const fn = ( ) => x . Value * x . Value * x . Value ; const memoized = memoizeOnce ( fn ) ; const closureWithoutCache = ( ) => { return fn ( ) ; } ; expect ( memoized ( ) ) . toBe ( closureWithoutCache ( ) ) ; x . Value = 10 ; expect ( memoized ( ) ) . not . toBe ( closureWithoutCache ( ) ) ; } ) ; } ) ;