-
Notifications
You must be signed in to change notification settings - Fork 55
UI Tests
Kevin Glen Roy Greer edited this page May 13, 2014
·
1 revision
FOAM now has support for unit/regression tests which run UI code.
Here's an example taken from demos/FOAMByExample.html:
<foam model="UITest" view="DemoView">
<name>View Tests</name>
<description>Test data-binding in TextFieldViews.</description>
<code>
var v1 = TextFieldView.create();
var v2 = TextFieldView.create();
render(v1);
render(v2);
v1.data$ = v2.data$;
</code>
</foam>
Notice that in the tag, the model is listed as "UITest" instead of the normal "UnitTest". UITest is a new sub-model of UnitTest, specificially designed to handle the testing of UI controls (either Views or CViews (Canvas Views)).
The other difference is that the tag is missing the regular onInit="this.test()" attribute. This is because UITests are not run until they are actually displayed, since they need a document in which to render.
UITests have a new support method called render(), which will render a View into the test results and then initialize it.