mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-14 17:53:11 +00:00
Provide browser DSL with location() to expect the iframe URL parts. Also move navigateTo() under the browser DSL.
This commit is contained in:
parent
2d61040fb0
commit
6bb2cd6ee2
5 changed files with 165 additions and 48 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -1,5 +1,16 @@
|
||||||
# <angular/> 0.9.2 faunal-mimicry (in-progress) #
|
# <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) #
|
# <angular/> 0.9.1 repulsion-field (2010-10-26) #
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
describe('personal log', function() {
|
describe('personal log', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
navigateTo('../personalLog.html');
|
browser().navigateTo('../personalLog.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,8 +64,8 @@ describe('personal log', function() {
|
||||||
element('form input[type="submit"]').click();
|
element('form input[type="submit"]').click();
|
||||||
expect(repeater('ul li').count()).toEqual(1);
|
expect(repeater('ul li').count()).toEqual(1);
|
||||||
|
|
||||||
navigateTo('about:blank');
|
browser().navigateTo('about:blank');
|
||||||
navigateTo('../personalLog.html');
|
browser().navigateTo('../personalLog.html');
|
||||||
|
|
||||||
expect(repeater('ul li').column('log.msg')).toEqual('my persistent message');
|
expect(repeater('ul li').column('log.msg')).toEqual('my persistent message');
|
||||||
expect(repeater('ul li').count()).toEqual(1);
|
expect(repeater('ul li').count()).toEqual(1);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
describe('widgets', function() {
|
describe('widgets', function() {
|
||||||
it('should verify that basic widgets work', 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');
|
using('#text-basic-box').input('text.basic').enter('Carlos');
|
||||||
expect(binding('text.basic')).toEqual('Carlos');
|
expect(binding('text.basic')).toEqual('Carlos');
|
||||||
|
|
@ -48,6 +48,7 @@ describe('widgets', function() {
|
||||||
|
|
||||||
element('#navigate a', "'Go to #route' link").click();
|
element('#navigate a', "'Go to #route' link").click();
|
||||||
expect(binding('$location.hash')).toEqual('route');
|
expect(binding('$location.hash')).toEqual('route');
|
||||||
|
expect(browser().location().hash()).toEqual('route');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom value parser for futures.
|
* Custom value parser for futures.
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,87 @@ angular.scenario.dsl('wait', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage:
|
* Usage:
|
||||||
* pause(seconds) pauses the test for specified number of seconds
|
* pause(seconds) pauses the test for specified number of seconds
|
||||||
*/
|
*/
|
||||||
angular.scenario.dsl('pause', function() {
|
angular.scenario.dsl('pause', function() {
|
||||||
return function(time) {
|
return function(time) {
|
||||||
return this.addFuture('pause for ' + time + ' seconds', function(done) {
|
return this.addFuture('pause for ' + time + ' seconds', function(done) {
|
||||||
this.$window.setTimeout(function() { done(null, time * 1000); }, time * 1000);
|
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;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,25 +120,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:
|
* Usage:
|
||||||
* using(selector, label) scopes the next DSL element selection
|
* using(selector, label) scopes the next DSL element selection
|
||||||
|
|
|
||||||
|
|
@ -87,26 +87,78 @@ describe("angular.scenario.dsl", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('NavigateTo', function() {
|
describe('Browser', function() {
|
||||||
it('should allow a string url', function() {
|
describe('NavigateTo', function() {
|
||||||
$root.dsl.navigateTo('http://myurl');
|
it('should allow a string url', function() {
|
||||||
expect($window.location).toEqual('http://myurl');
|
$root.dsl.browser().navigateTo('http://myurl');
|
||||||
expect($root.futureResult).toEqual('http://myurl');
|
expect($window.location).toEqual('http://myurl');
|
||||||
});
|
expect($root.futureResult).toEqual('http://myurl');
|
||||||
|
});
|
||||||
it('should allow a future url', function() {
|
|
||||||
$root.dsl.navigateTo('http://myurl', function() {
|
it('should allow a future url', function() {
|
||||||
return 'http://futureUrl/';
|
$root.dsl.browser().navigateTo('http://myurl', function() {
|
||||||
|
return 'http://futureUrl/';
|
||||||
|
});
|
||||||
|
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.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() {
|
describe('Location', function() {
|
||||||
delete $window.angular;
|
beforeEach(function() {
|
||||||
$root.dsl.navigateTo('http://myurl');
|
$window.location = {
|
||||||
expect($window.location).toEqual('http://myurl');
|
href: 'http://myurl/some/path?foo=10#/bar?x=2',
|
||||||
expect($root.futureResult).toEqual('http://myurl');
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue