Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evan-liu/as3-signals-utilities-async
Async test support for as3-signals
https://github.com/evan-liu/as3-signals-utilities-async
Last synced: 3 months ago
JSON representation
Async test support for as3-signals
- Host: GitHub
- URL: https://github.com/evan-liu/as3-signals-utilities-async
- Owner: evan-liu
- License: mit
- Created: 2010-01-06T12:23:11.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2012-02-20T02:05:16.000Z (over 12 years ago)
- Last Synced: 2024-06-23T20:44:58.672Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 347 KB
- Stars: 50
- Watchers: 5
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.textile
- License: MIT-LICENSE.txt
Awesome Lists containing this project
- awesome-actionscript-sorted - as3-signals-utilities-async - Async test support for as3-signals (Utilities / Other Utilities)
README
h2. Utility classes for unit test signals.
This library is a utility for "Robert Penner":http://robertpenner.com/ 's "as3-signals":http://github.com/robertpenner/as3-signals with some delegate methods to test them with FlexUnit4:
* proceedOnSignal
* handleSignal
* failOnSignal
* registerFailureSignalh3. proceedOnSignal
Use this method to ensure that some signal is dispatched during an asynchronous test.
[Test(async)]
public function test_proceedOnSignal():void
{
var model:IModel = new SomeModel();
proceedOnSignal(this, model.changedSignal);
model.doSomethingChange();
}h3. handleSignal
Use this method to ensure that some signal is dispatched and do more assertions in the handler. The handler method must have two arguments. The first one is a SignalAsyncEvent, you can get all arguments passed by the signal's dispatch() method by event.args. The second Object typed argument is the data passed by the passThroughData argument in the handleSignal method.
[Test(async)]
public function change_user():void
{
var model:IModel = new SomeModel();
handleSignal(this, model.changedSignal, verify_user, 500, {name:"Tom", age:20});
model.changeUser("Tom", 20);
}
private function verify_user(event:SignalAsyncEvent, data:Object):void
{
assertEquals(event.args[ 0 ], data.name);
assertEquals(event.args[ 1 ], data.age);
}h3. failOnSignal
Use this method to ensure that some signal is not dispatched during an asynchronous test in a time period.
[Test(async)]
public function not_changed():void
{
var model:IModel = new SomeModel();
failOnSignal(model.changedSignal);
model.doSomethingNotChange();
}h3. registerFailureSignal
Use this method to fail a test when a signal is dispatched. Think you are waiting for a success signal of a service, you will want to fail the test when the service's error signal is dispatched instead of waiting until timeout.
[Test(async)]
public function call_service():void
{
var service:IService = new SomeService();
registerFailureSignal(this, service.failedSignal);
proceedOnSignal(this, service.successSignal);
service.call();
}