-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Hi Drew
I try to use expect() instead received() and find the problem (received() works properly). Clean test below
package {
import flash.events.Event;
import flash.events.EventDispatcher;
import mockolate.arg;
import mockolate.expect;
import mockolate.runner.MockolateRule;
import org.hamcrest.core.anything;
import org.hamcrest.object.hasProperty;
public class FoobarTest {
[Rule]
public var rule:MockolateRule = new MockolateRule();
[Mock]
public var ed:EventDispatcher;
[Test]
public function works():void {
expect(ed.dispatchEvent(arg(anything()))).twice();
expect(ed.dispatchEvent(arg(hasProperty('type', '1'))));
expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));
ed.dispatchEvent(new Event('1'));
ed.dispatchEvent(new Event('2'))
}
[Test]
public function notWorks():void {
expect(ed.dispatchEvent(arg(anything()))).thrice();
expect(ed.dispatchEvent(arg(hasProperty('type', '1')))).twice();
expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));
ed.dispatchEvent(new Event('1'));
ed.dispatchEvent(new Event('1'));
ed.dispatchEvent(new Event('2'))
}
[Test]
public function butAgainWorks():void {
expect(ed.dispatchEvent(arg(hasProperty('type', '1')))).twice();
expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));
ed.dispatchEvent(new Event('1'));
ed.dispatchEvent(new Event('1'));
ed.dispatchEvent(new Event('2'))
}
}
}Metadata
Metadata
Assignees
Labels
No labels