mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-09 17:41:01 +00:00
Merge branch 'master' of github.com:angular/angular.js
This commit is contained in:
commit
f6ff0521ad
2 changed files with 51 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
angular.scenario.dsl.browser = {
|
||||
navigateTo: function(url){
|
||||
var location = this.location;
|
||||
return $scenario.addFuture('Navigate to: ' + url, function(done){
|
||||
var self = this;
|
||||
this.testFrame.load(function(){
|
||||
|
|
@ -15,8 +16,22 @@ angular.scenario.dsl.browser = {
|
|||
this.testFrame[0].contentWindow.location.reload();
|
||||
} else {
|
||||
this.testFrame.attr('src', url);
|
||||
location.setLocation(url);
|
||||
}
|
||||
});
|
||||
},
|
||||
location: {
|
||||
href: "",
|
||||
hash: "",
|
||||
toEqual: function(url) {
|
||||
return (this.hash == "" ? (url == this.href) :
|
||||
(url == (this.href + "/#/" + this.hash)));
|
||||
},
|
||||
setLocation: function(url) {
|
||||
var urlParts = url.split("/#/");
|
||||
this.href = urlParts[0] || "";
|
||||
this.hash = urlParts[1] || "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ describe("DSL", function() {
|
|||
setUpContext();
|
||||
executeFuture = function(future, html, callback) {
|
||||
lastDocument = _jQuery('<div>' + html + '</div>');
|
||||
lastFrame = _jQuery('<iframe>' + lastDocument + '</iframe>');
|
||||
_jQuery(document.body).append(lastDocument);
|
||||
var specThis = {
|
||||
testWindow: window,
|
||||
testDocument: lastDocument,
|
||||
testFrame: lastFrame,
|
||||
jQuery: _jQuery
|
||||
};
|
||||
future.behavior.call(specThis, callback || noop);
|
||||
|
|
@ -39,6 +41,38 @@ describe("DSL", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('browser', function() {
|
||||
var browser = angular.scenario.dsl.browser;
|
||||
it('shoud return true if location with empty hash provided is same '
|
||||
+ 'as location of the page', function() {
|
||||
browser.location.href = "http://server";
|
||||
expect(browser.location.toEqual("http://server")).toEqual(true);
|
||||
});
|
||||
it('shoud return true if location with hash provided is same '
|
||||
+ 'as location of the page', function() {
|
||||
browser.location.href = "http://server";
|
||||
browser.location.hash = "hashPath";
|
||||
expect(browser.location.toEqual("http://server/#/hashPath"))
|
||||
.toEqual(true);
|
||||
});
|
||||
it('should return true if the location provided is the same as which '
|
||||
+ 'browser navigated to', function() {
|
||||
var future = browser.navigateTo("http://server/#/hashPath");
|
||||
expect(future.name).toEqual("Navigate to: http://server/#/hashPath");
|
||||
executeFuture(future, '<input type="text" name="name" />');
|
||||
expect(browser.location.toEqual("http://server/#/hashPath"))
|
||||
.toEqual(true);
|
||||
expect(browser.location.toEqual("http://server/"))
|
||||
.toEqual(false);
|
||||
|
||||
future = browser.navigateTo("http://server/");
|
||||
expect(future.name).toEqual("Navigate to: http://server/");
|
||||
executeFuture(future, '<input type="text" name="name" />');
|
||||
expect(browser.location.toEqual("http://server/"))
|
||||
.toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('repeater', function() {
|
||||
|
||||
var repeater = angular.scenario.dsl.repeater;
|
||||
|
|
@ -125,7 +159,7 @@ describe("DSL", function() {
|
|||
expect(future.fulfilled).toBeTruthy();
|
||||
}
|
||||
it('should find elements on the page and provide jquery api', function() {
|
||||
var future = element('.reports-detail');
|
||||
var future = element('.reports-detail').find();
|
||||
expect(future.name).toEqual("Find element '.reports-detail'");
|
||||
timeTravel(future);
|
||||
expect(future.value.text()).
|
||||
|
|
@ -134,7 +168,7 @@ describe("DSL", function() {
|
|||
toEqual('Description : Details...');
|
||||
});
|
||||
it('should find elements with angular syntax', function() {
|
||||
var future = element('{{report.description}}');
|
||||
var future = element('{{report.description}}').find();
|
||||
expect(future.name).toEqual("Find element '{{report.description}}'");
|
||||
timeTravel(future);
|
||||
expect(future.value.text()).toEqual('Details...');
|
||||
|
|
|
|||
Loading…
Reference in a new issue