aboutsummaryrefslogtreecommitdiffstats
path: root/src/scenario/DSL.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/scenario/DSL.js')
-rw-r--r--src/scenario/DSL.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
new file mode 100644
index 00000000..4bc21d6c
--- /dev/null
+++ b/src/scenario/DSL.js
@@ -0,0 +1,47 @@
+angular.scenario.dsl.browser = {
+ navigateTo: function(url){
+ $scenario.addStep('Navigate to: ' + url, function(done){
+ var self = this;
+ self.testFrame.load(function(){
+ self.testFrame.unbind();
+ self.testDocument = jQuery(self.testWindow.document);
+ done();
+ });
+ if (this.testFrame.attr('src') == url) {
+ this.testWindow.location.reload();
+ } else {
+ this.testFrame.attr('src', url);
+ }
+ });
+ }
+};
+
+angular.scenario.dsl.input = function(selector) {
+ return {
+ enter: function(value){
+ $scenario.addStep("Set input text of '" + selector + "' to value '" +
+ value + "'", function(done){
+ var input = this.testDocument.find('input[name=' + selector + ']');
+ input.val(value);
+ input.trigger('change');
+ this.testWindow.angular.element(input[0]).trigger('change');
+ done();
+ });
+ }
+ };
+};
+
+angular.scenario.dsl.expect = function(selector) {
+ return {
+ toEqual: function(expected) {
+ $scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){
+ var attrName = selector.substring(2, selector.length - 2);
+ var binding = this.testDocument.find('span[ng-bind=' + attrName + ']');
+ if (binding.text() != expected) {
+ this.result.fail("Expected '" + expected + "' but was '" + binding.text() + "'");
+ }
+ done();
+ });
+ }
+ };
+};