Flexunit testing a TweenMax that calls a function.

123 views Asked by At

How do I unit test the forexample() function to make sure that the function is called within the delayed time?

private var done : Boolean;

private function forexample():void
{
    done = false;
    TweenMax.delayedCall(3 , toBeCalledFunctionNane);
}

private function toBeCalledFunctionNane():void
{
    done  = true;
}
1

There are 1 answers

2
Gio On

It works I assure you, but if you want to see it yourself you can try this:

private var callRegistered : uint = 0;

private function forexample():void
{
    callRegistered = getTimer();
    TweenMax.delayedCall(3 , toBeCalledFunctionNane);
}

private function toBeCalledFunctionNane():void
{
    trace("Function was called after:", getTimer() - callRegistered);
}

This will trace out the time in which the function was called in milliseconds.

P.S. You'll have to add this import statement to use the getTimer() method:

import flash.utils.getTimer;