Created
June 13, 2011 11:37
-
-
Save newtriks/1022643 to your computer and use it in GitHub Desktop.
SearchView Test Class using ASUnit4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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"); | |
} | |
} | |
} |
Author
newtriks
commented
Oct 11, 2011
via email
Good question and I have no idea ;) I wonder if I had copied it from a one of the test classes in the asunit source or is it nowhere I the test classes either?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment