diff --git a/modules/angular2/test/router/location_spec.ts b/modules/angular2/test/router/location_spec.ts index 261c21760e..034e5da30e 100644 --- a/modules/angular2/test/router/location_spec.ts +++ b/modules/angular2/test/router/location_spec.ts @@ -105,5 +105,13 @@ export function main() { location.back(); assertUrl('/ready'); }); + + it('should incorporate the provided query values into the location change', () => { + var locationStrategy = new MockLocationStrategy(); + var location = new Location(locationStrategy); + + location.go('/home', "key=value"); + expect(location.path()).toEqual("/home?key=value"); + }); }); } diff --git a/modules/examples/e2e_test/routing/routing_spec.ts b/modules/examples/e2e_test/routing/routing_spec.ts index 9617ad8609..2fa61337ec 100644 --- a/modules/examples/e2e_test/routing/routing_spec.ts +++ b/modules/examples/e2e_test/routing/routing_spec.ts @@ -7,20 +7,20 @@ function waitForElement(selector) { browser.wait(EC.presenceOf($(selector)), 20000); } -describe('routing inbox-app', function() { +describe('routing inbox-app', () => { afterEach(verifyNoBrowserErrors); - describe('index view', function() { + describe('index view', () => { var URL = 'examples/src/routing/'; - it('should list out the current collection of items', function() { + it('should list out the current collection of items', () => { browser.get(URL); waitForElement('.inbox-item-record'); expect(element.all(by.css('.inbox-item-record')).count()).toEqual(200); }); - it('should build a link which points to the detail page', function() { + it('should build a link which points to the detail page', () => { browser.get(URL); waitForElement('#item-15'); expect(element(by.css('#item-15')).getAttribute('href')).toMatch(/\/detail\/15$/); @@ -31,10 +31,10 @@ describe('routing inbox-app', function() { }); - describe('drafts view', function() { + describe('drafts view', () => { var URL = 'examples/src/routing/#/drafts'; - it('should navigate to the drafts view when the drafts link is clicked', function() { + it('should navigate to the drafts view when the drafts link is clicked', () => { browser.get(URL); waitForElement('.inbox-item-record'); element(by.linkText('Drafts')).click(); @@ -42,7 +42,7 @@ describe('routing inbox-app', function() { expect(element(by.css('.page-title')).getText()).toEqual('Drafts'); }); - it('should navigate to email details', function() { + it('should navigate to email details', () => { browser.get(URL); element(by.linkText('Drafts')).click(); waitForElement('.inbox-item-record'); @@ -55,10 +55,10 @@ describe('routing inbox-app', function() { }); - describe('detail view', function() { + describe('detail view', () => { var URL = 'examples/src/routing/'; - it('should navigate to the detail view when an email is clicked', function() { + it('should navigate to the detail view when an email is clicked', () => { browser.get(URL); waitForElement('#item-10'); element(by.css('#item-10')).click(); @@ -68,13 +68,25 @@ describe('routing inbox-app', function() { expect(recordId.getText()).toEqual('ID: 10'); }); - it('should navigate back to the email inbox page when the back button is clicked', function() { + it('should navigate back to the email inbox page when the back button is clicked', () => { browser.get(URL); waitForElement('#item-10'); element(by.css('#item-10')).click(); waitForElement('.back-button'); element(by.css('.back-button')).click(); - expect(browser.getCurrentUrl()).toMatch('/#'); + expect(browser.getCurrentUrl()).toMatch(/\/$/); }); + + it('should navigate back to index and sort the page items based on the provided querystring param', + () => { + browser.get(URL); + waitForElement('#item-10'); + element(by.css('#item-10')).click(); + waitForElement('.sort-button'); + element(by.css('.sort-button')).click(); + expect(browser.getCurrentUrl()).toMatch(/\/#\?sort=date$/); + waitForElement('.inbox-item-record'); + expect(element(by.css(".inbox-item-record > a")).getAttribute("id")).toEqual("item-137"); + }); }) });