From 449d2ef7246b029eb927261526dc1b907ffa3734 Mon Sep 17 00:00:00 2001
From: Shyam Seshadri
Date: Sat, 14 Aug 2010 00:31:06 +0800
Subject: Pull in Rajat's changes to add click and url checking dsl
---
src/scenario/DSL.js | 50 ++++++++++++++++++++++++++++++++++++------------
test/scenario/DSLSpec.js | 45 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 81 insertions(+), 14 deletions(-)
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
index 3b049dc6..ca944014 100644
--- a/src/scenario/DSL.js
+++ b/src/scenario/DSL.js
@@ -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] || "";
+ }
}
};
@@ -88,17 +103,28 @@ angular.scenario.dsl.repeater = function(selector) {
angular.scenario.dsl.element = function(selector) {
var nameSuffix = "element '" + selector + "'";
- return $scenario.addFuture('Find ' + nameSuffix, function(done) {
- var self = this, repeaterArray = [], ngBindPattern;
- var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN);
- if (startIndex >= 0) {
- ngBindPattern = selector.substring(startIndex + 2, selector.length - 2);
- var element = this.testDocument.find('*').filter(function() {
- return self.jQuery(this).attr('ng:bind') == ngBindPattern;
- });
- done(element);
- } else {
- done(this.testDocument.find(selector));
+ return {
+ find: function() {
+ return $scenario.addFuture('Find ' + nameSuffix, function(done) {
+ var self = this, repeaterArray = [], ngBindPattern;
+ var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN);
+ if (startIndex >= 0) {
+ ngBindPattern = selector.substring(startIndex + 2, selector.length - 2);
+ var element = this.testDocument.find('*').filter(function() {
+ return self.jQuery(this).attr('ng:bind') == ngBindPattern;
+ });
+ done(element);
+ } else {
+ done(this.testDocument.find(selector));
+ }
+ });
+ },
+ click: function() {
+ var self = this;
+ return $scenario.addFuture('Click ' + nameSuffix, function(done) {
+ _jQuery(self).click();
+ done();
+ });
}
- });
+ };
};
diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js
index c8e30917..9bf6d31d 100644
--- a/test/scenario/DSLSpec.js
+++ b/test/scenario/DSLSpec.js
@@ -6,10 +6,12 @@ describe("DSL", function() {
setUpContext();
executeFuture = function(future, html, callback) {
lastDocument = _jQuery('
' + html + '
');
+ lastFrame = _jQuery('');
_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, '');
+ 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, '');
+ 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,11 +168,18 @@ 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...');
expect(future.value.attr('ng:bind')).toEqual('report.description');
});
+ it('should be able to click elements', function(){
+ var future = element('.link-class').click();
+ expect(future.name).toEqual("Click element '.link-class'");
+ executeFuture(future, html, function(value) { future.fulfill(value); });
+ expect(future.fulfilled).toBeTruthy();
+ // TODO(rajat): look for some side effect from click happening?
+ });
});
});
--
cgit v1.2.3
From f6527bd53c1d80c7db549b22ecf3aa02e96cda1f Mon Sep 17 00:00:00 2001
From: Shyam Seshadri
Date: Sat, 14 Aug 2010 00:45:56 +0800
Subject: Revert click dsl, since what is returned by element is a jquery
object
---
src/scenario/DSL.js | 35 ++++++++++++-----------------------
test/scenario/DSLSpec.js | 7 -------
2 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
index ca944014..a64f8548 100644
--- a/src/scenario/DSL.js
+++ b/src/scenario/DSL.js
@@ -103,28 +103,17 @@ angular.scenario.dsl.repeater = function(selector) {
angular.scenario.dsl.element = function(selector) {
var nameSuffix = "element '" + selector + "'";
- return {
- find: function() {
- return $scenario.addFuture('Find ' + nameSuffix, function(done) {
- var self = this, repeaterArray = [], ngBindPattern;
- var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN);
- if (startIndex >= 0) {
- ngBindPattern = selector.substring(startIndex + 2, selector.length - 2);
- var element = this.testDocument.find('*').filter(function() {
- return self.jQuery(this).attr('ng:bind') == ngBindPattern;
- });
- done(element);
- } else {
- done(this.testDocument.find(selector));
- }
- });
- },
- click: function() {
- var self = this;
- return $scenario.addFuture('Click ' + nameSuffix, function(done) {
- _jQuery(self).click();
- done();
- });
+ return $scenario.addFuture('Find ' + nameSuffix, function(done) {
+ var self = this, repeaterArray = [], ngBindPattern;
+ var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN);
+ if (startIndex >= 0) {
+ ngBindPattern = selector.substring(startIndex + 2, selector.length - 2);
+ var element = this.testDocument.find('*').filter(function() {
+ return self.jQuery(this).attr('ng:bind') == ngBindPattern;
+ });
+ done(element);
+ } else {
+ done(this.testDocument.find(selector));
}
- };
+ });
};
diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js
index 9bf6d31d..ccd9e32b 100644
--- a/test/scenario/DSLSpec.js
+++ b/test/scenario/DSLSpec.js
@@ -174,12 +174,5 @@ describe("DSL", function() {
expect(future.value.text()).toEqual('Details...');
expect(future.value.attr('ng:bind')).toEqual('report.description');
});
- it('should be able to click elements', function(){
- var future = element('.link-class').click();
- expect(future.name).toEqual("Click element '.link-class'");
- executeFuture(future, html, function(value) { future.fulfill(value); });
- expect(future.fulfilled).toBeTruthy();
- // TODO(rajat): look for some side effect from click happening?
- });
});
});
--
cgit v1.2.3
From 68900e2039e80f9279bbde9a56753aaa342a2eb7 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 13 Aug 2010 10:05:25 -0700
Subject: learning about git head
---
perf/buzz_raw.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/perf/buzz_raw.html b/perf/buzz_raw.html
index fb1144af..ff86ff70 100644
--- a/perf/buzz_raw.html
+++ b/perf/buzz_raw.html
@@ -20,6 +20,7 @@
};
}
window.browser = time('boot:');
+