Skip to content

Instantly share code, notes, and snippets.

@newtriks
Created June 13, 2011 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newtriks/1022643 to your computer and use it in GitHub Desktop.
Save newtriks/1022643 to your computer and use it in GitHub Desktop.
SearchView Test Class using ASUnit4
/** @author: Simon Bailey <simon@newtriks.com> */
package
{
import asunit.asserts.assertNotNull;
import asunit.asserts.assertSame;
import asunit.asserts.assertTrue;
import asunit.framework.IAsync;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.setTimeout;
public class SearchViewTest
{
[Inject]
public var context:Sprite;
[Inject]
public var async:IAsync;
private var searchView:SearchView;
[Before]
public function setUp():void
{
searchView=new SearchView();
context.addChild(searchView);
}
[After]
public function tearDown():void
{
searchView=null;
}
[Test]
public function instantiated():void
{
assertTrue(searchView is SearchView);
}
[Test]
public function search_view_has_search_textinput():void
{
assertNotNull(searchView.searchRequest_txt);
}
[Test]
public function search_text_is_populated():void
{
searchView.searchRequest_txt.text="Hello World";
assertSame(searchView.searchRequest_txt.text, "Hello World");
}
[Test]
public function submit_button_dispatches_specific_eventname():void
{
searchView.addEventListener("submitSearchEvent", async.add(submitDispatchesSpecificEventType));
searchView.submit_btn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
protected function submitDispatchesSpecificEventType(event:Event):void
{
assertSame(event.type, "submitSearchEvent");
}
}
}
@robertpenner
Copy link

Why do you have this?
use namespace assertSame;

@newtriks
Copy link
Author

newtriks commented Oct 11, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment