From 669d8241b2ea61122aee3e45f67694e65596a2dd 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 --- test/scenario/DSLSpec.js | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'test/scenario') 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 1f230bf3f55fc8541423dfa9fc0bc91f50c000a3 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 --- test/scenario/DSLSpec.js | 7 ------- 1 file changed, 7 deletions(-) (limited to 'test/scenario') 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 9260f4867a6d1aaa51585a3efac9d315b74eae53 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 01:11:11 +0800 Subject: Fix broken tests for element dsl --- test/scenario/DSLSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/scenario') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index ccd9e32b..552e6211 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -159,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').find(); + var future = element('.reports-detail'); expect(future.name).toEqual("Find element '.reports-detail'"); timeTravel(future); expect(future.value.text()). @@ -168,7 +168,7 @@ describe("DSL", function() { toEqual('Description : Details...'); }); it('should find elements with angular syntax', function() { - var future = element('{{report.description}}').find(); + var future = element('{{report.description}}'); expect(future.name).toEqual("Find element '{{report.description}}'"); timeTravel(future); expect(future.value.text()).toEqual('Details...'); -- cgit v1.2.3 From 60eeeb9f20be3220dbb891abef848fe3754437da Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 03:05:50 +0800 Subject: Provide all jquery functions as futures --- test/scenario/DSLSpec.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'test/scenario') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index 552e6211..f8606641 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -159,20 +159,27 @@ describe("DSL", function() { expect(future.fulfilled).toBeTruthy(); } it('should find elements on the page and provide jquery api', function() { - var future = element('.reports-detail'); - expect(future.name).toEqual("Find element '.reports-detail'"); + var future = element('.reports-detail').text(); + expect(future.name).toEqual("Element '.reports-detail'.text()"); timeTravel(future); - expect(future.value.text()). + expect(future.value). toEqual('Description : Details...Date created: 01/01/01'); - expect(future.value.find('.desc').text()). - toEqual('Description : Details...'); +// expect(future.value.find('.desc').text()). +// toEqual('Description : Details...'); }); it('should find elements with angular syntax', function() { - var future = element('{{report.description}}'); - expect(future.name).toEqual("Find element '{{report.description}}'"); + var future = element('{{report.description}}').text(); + expect(future.name).toEqual("Element '{{report.description}}'.text()"); timeTravel(future); - expect(future.value.text()).toEqual('Details...'); - expect(future.value.attr('ng:bind')).toEqual('report.description'); + expect(future.value).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("Element '.link-class'.click()"); + 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