aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/Steps.js
diff options
context:
space:
mode:
authorAdam Abrons2010-01-05 16:36:58 -0800
committerAdam Abrons2010-01-05 16:36:58 -0800
commitc9c176a53b1632ca2b1c6ed27382ab72ac21d45d (patch)
treeb5f719a095c03ee9f8b2721ffdaf1e5ff8c11b41 /src/test/Steps.js
downloadangular.js-c9c176a53b1632ca2b1c6ed27382ab72ac21d45d.tar.bz2
angular.js
Diffstat (limited to 'src/test/Steps.js')
-rw-r--r--src/test/Steps.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/Steps.js b/src/test/Steps.js
new file mode 100644
index 00000000..af4b84d6
--- /dev/null
+++ b/src/test/Steps.js
@@ -0,0 +1,57 @@
+angular.test.GIVEN = {
+ browser:function(){
+ var self = this;
+ if (jQuery.browser.safari && this.frame.attr('src') == this.at) {
+ this.window.location.reload();
+ } else {
+ this.frame.attr('src', this.at);
+ }
+ return function(done){
+ self.frame.load(function(){
+ self.frame.unbind();
+ done();
+ });
+ };
+ },
+ dataset:function(){
+ this.frame.name="$DATASET:" + nglr.toJson({dataset:this.dataset});
+ }
+};
+angular.test.WHEN = {
+ enter:function(){
+ var element = this.element(this.at);
+ element.attr('value', this.text);
+ element.change();
+ },
+ click:function(){
+ var element = this.element(this.at);
+ var input = element[0];
+ // emulate the browser behavior which causes it
+ // to be overridden at the end.
+ var checked = input.checked = !input.checked;
+ element.click();
+ input.checked = checked;
+ },
+ select:function(){
+ var element = this.element(this.at);
+ var path = "option[value=" + this.option + "]";
+ var option = this.assert(element.find(path));
+ option[0].selected = !option[0].selected;
+ element.change();
+ }
+};
+angular.test.THEN = {
+ text:function(){
+ var element = this.element(this.at);
+ if (typeof this.should_be != undefined ) {
+ var should_be = this.should_be;
+ if (_.isArray(this.should_be))
+ should_be = JSON.stringify(should_be);
+ if (element.text() != should_be)
+ throw "Expected " + should_be +
+ " but was " + element.text() + ".";
+ }
+ },
+ drainRequestQueue:function(){
+ }
+};