aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Sprehn2010-10-29 16:02:57 -0700
committerElliott Sprehn2010-11-01 15:21:37 -0700
commit6bb2cd6ee2a35768ac4422395596daf1438e62ff (patch)
tree86c52c03c886116176b8df9afa482fb886538963
parent2d61040fb085f5d3a226d39726e105c1e6bd7006 (diff)
downloadangular.js-6bb2cd6ee2a35768ac4422395596daf1438e62ff.tar.bz2
Provide browser DSL with location() to expect the iframe URL parts. Also move navigateTo() under the browser DSL.
-rw-r--r--CHANGELOG.md11
-rw-r--r--example/personalLog/scenario/personalLogScenario.js6
-rw-r--r--scenario/widgets-scenario.js3
-rw-r--r--src/scenario/dsl.js107
-rw-r--r--test/scenario/dslSpec.js84
5 files changed, 164 insertions, 47 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0b2add6..9067d87c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# <angular/> 0.9.2 faunal-mimicry (in-progress) #
+### Testability
+- binding DSL in Scenario can now match bindings without specifying filters
+- dsl statements now accept a label argument to make test output more readable (issue #94)
+- dsl element() statement now implements most of the jQuery API (issue #106)
+- file:// URLs are no longer supported for running a scenario. You must use a web server that implements HEAD
+- new browser() dsl statement for getting info about the emulated browser running the app (issue #109)
+- navigateTo() is now browser().navigateTo(). Old code must be updated
+- navigating to about:blank is no longer supported. It results in a sandbox error
+- scenario runner is now compatible with IE8 (issue #93)
+- scenarior runner checks if URL would return a non-success status code (issue #100)
+
# <angular/> 0.9.1 repulsion-field (2010-10-26) #
diff --git a/example/personalLog/scenario/personalLogScenario.js b/example/personalLog/scenario/personalLogScenario.js
index 3679a33c..09ceae28 100644
--- a/example/personalLog/scenario/personalLogScenario.js
+++ b/example/personalLog/scenario/personalLogScenario.js
@@ -1,7 +1,7 @@
describe('personal log', function() {
beforeEach(function() {
- navigateTo('../personalLog.html');
+ browser().navigateTo('../personalLog.html');
});
@@ -64,8 +64,8 @@ describe('personal log', function() {
element('form input[type="submit"]').click();
expect(repeater('ul li').count()).toEqual(1);
- navigateTo('about:blank');
- navigateTo('../personalLog.html');
+ browser().navigateTo('about:blank');
+ browser().navigateTo('../personalLog.html');
expect(repeater('ul li').column('log.msg')).toEqual('my persistent message');
expect(repeater('ul li').count()).toEqual(1);
diff --git a/scenario/widgets-scenario.js b/scenario/widgets-scenario.js
index cf482d46..f5b923c3 100644
--- a/scenario/widgets-scenario.js
+++ b/scenario/widgets-scenario.js
@@ -1,6 +1,6 @@
describe('widgets', function() {
it('should verify that basic widgets work', function(){
- navigateTo('widgets.html');
+ browser().navigateTo('widgets.html');
using('#text-basic-box').input('text.basic').enter('Carlos');
expect(binding('text.basic')).toEqual('Carlos');
@@ -48,6 +48,7 @@ describe('widgets', function() {
element('#navigate a', "'Go to #route' link").click();
expect(binding('$location.hash')).toEqual('route');
+ expect(browser().location().hash()).toEqual('route');
/**
* Custom value parser for futures.
diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js
index 8235e9e0..b2270cea 100644
--- a/src/scenario/dsl.js
+++ b/src/scenario/dsl.js
@@ -16,15 +16,87 @@ angular.scenario.dsl('wait', function() {
});
/**
-* Usage:
-* pause(seconds) pauses the test for specified number of seconds
-*/
+ * Usage:
+ * pause(seconds) pauses the test for specified number of seconds
+ */
angular.scenario.dsl('pause', function() {
- return function(time) {
- return this.addFuture('pause for ' + time + ' seconds', function(done) {
- this.$window.setTimeout(function() { done(null, time * 1000); }, time * 1000);
- });
- };
+ return function(time) {
+ return this.addFuture('pause for ' + time + ' seconds', function(done) {
+ this.$window.setTimeout(function() { done(null, time * 1000); }, time * 1000);
+ });
+ };
+});
+
+/**
+ * Usage:
+ * browser().navigateTo(url) Loads the url into the frame
+ * browser().navigateTo(url, fn) where fn(url) is called and returns the URL to navigate to
+ * browser().location().href() the full URL of the page
+ * browser().location().hash() the full hash in the url
+ * browser().location().path() the full path in the url
+ * browser().location().hashSearch() the hashSearch Object from angular
+ * browser().location().hashPath() the hashPath string from angular
+ */
+angular.scenario.dsl('browser', function() {
+ var chain = {};
+
+ chain.navigateTo = function(url, delegate) {
+ var application = this.application;
+ return this.addFuture('browser navigate to ' + url, function(done) {
+ if (delegate) {
+ url = delegate.call(this, url);
+ }
+ application.navigateTo(url, function() {
+ done(null, url);
+ }, done);
+ });
+ };
+
+ chain.location = function() {
+ var api = {};
+
+ api.href = function() {
+ return this.addFutureAction('browser url', function($window, $document, done) {
+ done(null, $window.location.href);
+ });
+ };
+
+ api.hash = function() {
+ return this.addFutureAction('browser url hash', function($window, $document, done) {
+ done(null, $window.location.hash.replace('#', ''));
+ });
+ };
+
+ api.path = function() {
+ return this.addFutureAction('browser url path', function($window, $document, done) {
+ done(null, $window.location.pathname);
+ });
+ };
+
+ api.search = function() {
+ return this.addFutureAction('browser url search', function($window, $document, done) {
+ done(null, $window.angular.scope().$location.search);
+ });
+ };
+
+ api.hashSearch = function() {
+ return this.addFutureAction('browser url hash search', function($window, $document, done) {
+ done(null, $window.angular.scope().$location.hashSearch);
+ });
+ };
+
+ api.hashPath = function() {
+ return this.addFutureAction('browser url hash path', function($window, $document, done) {
+ done(null, $window.angular.scope().$location.hashPath);
+ });
+ };
+
+ return api;
+ };
+
+ return function(time) {
+ return chain;
+ };
});
/**
@@ -50,25 +122,6 @@ angular.scenario.dsl('expect', function() {
/**
* Usage:
- * navigateTo(url) Loads the url into the frame
- * navigateTo(url, fn) where fn(url) is called and returns the URL to navigate to
- */
-angular.scenario.dsl('navigateTo', function() {
- return function(url, delegate) {
- var application = this.application;
- return this.addFuture('navigate to ' + url, function(done) {
- if (delegate) {
- url = delegate.call(this, url);
- }
- application.navigateTo(url, function() {
- done(null, url);
- }, done);
- });
- };
-});
-
-/**
- * Usage:
* using(selector, label) scopes the next DSL element selection
*
* ex.
diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js
index ecb5d3e7..cc002612 100644
--- a/test/scenario/dslSpec.js
+++ b/test/scenario/dslSpec.js
@@ -87,26 +87,78 @@ describe("angular.scenario.dsl", function() {
});
});
- describe('NavigateTo', function() {
- it('should allow a string url', function() {
- $root.dsl.navigateTo('http://myurl');
- expect($window.location).toEqual('http://myurl');
- expect($root.futureResult).toEqual('http://myurl');
- });
+ describe('Browser', function() {
+ describe('NavigateTo', function() {
+ it('should allow a string url', function() {
+ $root.dsl.browser().navigateTo('http://myurl');
+ expect($window.location).toEqual('http://myurl');
+ expect($root.futureResult).toEqual('http://myurl');
+ });
+
+ it('should allow a future url', function() {
+ $root.dsl.browser().navigateTo('http://myurl', function() {
+ return 'http://futureUrl/';
+ });
+ expect($window.location).toEqual('http://futureUrl/');
+ expect($root.futureResult).toEqual('http://futureUrl/');
+ });
- it('should allow a future url', function() {
- $root.dsl.navigateTo('http://myurl', function() {
- return 'http://futureUrl/';
+ it('should complete if angular is missing from app frame', function() {
+ delete $window.angular;
+ $root.dsl.browser().navigateTo('http://myurl');
+ expect($window.location).toEqual('http://myurl');
+ expect($root.futureResult).toEqual('http://myurl');
});
- expect($window.location).toEqual('http://futureUrl/');
- expect($root.futureResult).toEqual('http://futureUrl/');
});
- it('should complete if angular is missing from app frame', function() {
- delete $window.angular;
- $root.dsl.navigateTo('http://myurl');
- expect($window.location).toEqual('http://myurl');
- expect($root.futureResult).toEqual('http://myurl');
+ describe('Location', function() {
+ beforeEach(function() {
+ $window.location = {
+ href: 'http://myurl/some/path?foo=10#/bar?x=2',
+ pathname: '/some/path',
+ search: '?foo=10',
+ hash: '#bar?x=2'
+ };
+ $window.angular.scope = function() {
+ return {
+ $location: {
+ hashSearch: {x: 2},
+ hashPath: '/bar',
+ search: {foo: 10}
+ }
+ };
+ };
+ });
+
+ it('should return full URL for href', function() {
+ $root.dsl.browser().location().href();
+ expect($root.futureResult).toEqual($window.location.href);
+ });
+
+ it('should return the pathname', function() {
+ $root.dsl.browser().location().path();
+ expect($root.futureResult).toEqual($window.location.pathname);
+ });
+
+ it('should return the hash without the #', function() {
+ $root.dsl.browser().location().hash();
+ expect($root.futureResult).toEqual('bar?x=2');
+ });
+
+ it('should return the query string as an object', function() {
+ $root.dsl.browser().location().search();
+ expect($root.futureResult).toEqual({foo: 10});
+ });
+
+ it('should return the hashSearch as an object', function() {
+ $root.dsl.browser().location().hashSearch();
+ expect($root.futureResult).toEqual({x: 2});
+ });
+
+ it('should return the hashPath', function() {
+ $root.dsl.browser().location().hashPath();
+ expect($root.futureResult).toEqual('/bar');
+ });
});
});