diff options
| author | Adam Abrons | 2010-03-15 17:02:54 -0700 |
|---|---|---|
| committer | Adam Abrons | 2010-03-15 17:02:54 -0700 |
| commit | 39c6c5975bedf6e1610f7328a088acda9ab3406a (patch) | |
| tree | c49a499733b7a3ec3547c64ff4d3ba5f9381dfa7 /src/scenario/Steps.js | |
| parent | 79b743e52feb2c57ba0ae42d6d2742bc2189b22f (diff) | |
| download | angular.js-39c6c5975bedf6e1610f7328a088acda9ab3406a.tar.bz2 | |
get scenarios running again - open Runner.html in a browser to run them
Diffstat (limited to 'src/scenario/Steps.js')
| -rw-r--r-- | src/scenario/Steps.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/scenario/Steps.js b/src/scenario/Steps.js new file mode 100644 index 00000000..f8ac173f --- /dev/null +++ b/src/scenario/Steps.js @@ -0,0 +1,57 @@ +angular.scenario.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:" + toJson({dataset:this.dataset}); + } +}; +angular.scenario.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.scenario.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(){ + } +}; |
