Permalink
Browse files

Abstracted string messages away from tests

Signed-off-by: Simon Bailey <simon@newtriks.com>
  • Loading branch information...
1 parent b6d44f5 commit 1f25a0220b38da968230b64b8fa28e6d4a93b31c @newtriks committed Jul 1, 2011
Showing with 15 additions and 10 deletions.
  1. +6 −2 src/SearchApplication.mxml
  2. +9 −8 test/com/newtriks/xendtoendtests/SearchWithResponseTest.as
@@ -14,15 +14,19 @@
horizontalAlign="center"/>
</s:layout>
<fx:Script><![CDATA[
+
+ public static const INPUT_EMPTY_MESSAGE:String="Error: Search input must not be empty!";
+ public static const REQUEST_LOG_MESSAGE:String="You submitted a search request for: ";
+
protected function searchView_submitSearchEventHandler(event:Event):void
{
if(searchView.searchRequest_txt.text=="")
{
- loggerView.logger_txt.text="Error: Search input must not be empty!";
+ loggerView.logger_txt.text=INPUT_EMPTY_MESSAGE;
}
else
{
- loggerView.logger_txt.text="You submitted a search request for: ".concat(searchView.searchRequest_txt.text);
+ loggerView.logger_txt.text=REQUEST_LOG_MESSAGE.concat(searchView.searchRequest_txt.text);
}
}
]]></fx:Script>
@@ -18,7 +18,6 @@ package com.newtriks.xendtoendtests
import com.newtriks.views.Logger;
import com.newtriks.views.SearchView;
- import flash.events.MouseEvent;
import flash.utils.setTimeout;
import spark.components.Button;
@@ -32,6 +31,8 @@ package com.newtriks.xendtoendtests
[Inject]
public var async:IAsync;
+ protected static const TEXT_ENTERED:String="Hello World";
+
private var robotEyes:RobotFlexEyes;
private var searchApplication:SearchApplication;
@@ -87,8 +88,8 @@ package com.newtriks.xendtoendtests
public function search_logger_contains_specific_string():void
{
var loggerTextDriver:TextAreaDriver=inViewOf(Logger).getA(TextArea).id("logger_txt") as TextAreaDriver;
- loggerTextDriver.enterText('Hello World');
- assertTrue(loggerTextDriver.textIs('Hello World'));
+ loggerTextDriver.enterText(TEXT_ENTERED);
+ assertTrue(loggerTextDriver.textIs(TEXT_ENTERED));
}
[Test]
@@ -118,31 +119,31 @@ package com.newtriks.xendtoendtests
{
var submitButtonDriver:InteractiveObjectDriver=inViewOf(SearchView).getA(Button).id("submit_btn") as InteractiveObjectDriver;
submitButtonDriver.click();
- var handler:Function = async.add(submitThrowsErrorClickHandler);
+ var handler:Function=async.add(submitThrowsErrorClickHandler);
setTimeout(handler, 0);
}
private function submitThrowsErrorClickHandler():void
{
var loggerTextDriver:TextAreaDriver=inViewOf(Logger).getA(TextArea).id("logger_txt") as TextAreaDriver;
- assertTrue(loggerTextDriver.textIs("Error: Search input must not be empty!"));
+ assertTrue(loggerTextDriver.textIs(SearchApplication.INPUT_EMPTY_MESSAGE));
}
[Test]
public function submits_successfully():void
{
var submitButtonDriver:InteractiveObjectDriver=inViewOf(SearchView).getA(Button).id("submit_btn") as InteractiveObjectDriver;
var textInputDriver:TextInputDriver=inViewOf(SearchView).getA(TextInput).id("searchRequest_txt") as TextInputDriver;
- textInputDriver.enterText('Hello World');
+ textInputDriver.enterText(TEXT_ENTERED);
submitButtonDriver.click();
- var handler:Function = async.add(submitClickHandler);
+ var handler:Function=async.add(submitClickHandler);
setTimeout(handler, 0);
}
private function submitClickHandler():void
{
var loggerTextDriver:TextAreaDriver=inViewOf(Logger).getA(TextArea).id("logger_txt") as TextAreaDriver;
- assertTrue(loggerTextDriver.textIs("You submitted a search request for: Hello World"));
+ assertTrue(loggerTextDriver.textIs(SearchApplication.REQUEST_LOG_MESSAGE.concat(TEXT_ENTERED)));
}
}
}

0 comments on commit 1f25a02

Please sign in to comment.