This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib): add support for waiting for angular2
Use Angular2's testability API, if present, when waiting for stability or loading a page. Closes #2396
- Loading branch information
Showing
4 changed files
with
136 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var env = require('./environment.js'); | ||
|
||
// This is the configuration for a smoke test for an Angular2 application. | ||
// | ||
// *** NOTE *** | ||
// As Angular2 is in rapid development, the test application that ships with | ||
// the Protractor repository does not yet contain an Angular2 section. This | ||
// configuration assumes that you are serving the examples from the | ||
// angular/angular repository at localhost:8000. | ||
// See https://github.com/angular/angular/blob/master/DEVELOPER.md for | ||
// setup instructions. | ||
// | ||
// TODO: when Angular2 is beta, include a test application in the | ||
// Protractor repository. | ||
exports.config = { | ||
seleniumAddress: env.seleniumAddress, | ||
|
||
framework: 'jasmine2', | ||
|
||
specs: [ | ||
'ng2/async_spec.js' | ||
], | ||
|
||
capabilities: env.capabilities, | ||
|
||
baseUrl: 'http://localhost:8000', | ||
|
||
rootElement: 'async-app' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
describe('async angular2 application', function() { | ||
var URL = 'examples/src/async/index.html'; | ||
|
||
beforeEach(function() { | ||
browser.get(URL); | ||
}); | ||
|
||
it('should work with synchronous actions', function() { | ||
var increment = $('#increment'); | ||
increment.$('.action').click(); | ||
|
||
expect(increment.$('.val').getText()).toEqual('1'); | ||
}); | ||
|
||
it('should wait for asynchronous actions', function() { | ||
var timeout = $('#delayedIncrement'); | ||
|
||
// At this point, the async action is still pending, so the count should | ||
// still be 0. | ||
expect(timeout.$('.val').getText()).toEqual('0'); | ||
|
||
timeout.$('.action').click(); | ||
|
||
expect(timeout.$('.val').getText()).toEqual('1'); | ||
}); | ||
|
||
it('should turn off when ignoreSynchronization is true', function() { | ||
var timeout = $('#delayedIncrement'); | ||
|
||
// At this point, the async action is still pending, so the count should | ||
// still be 0. | ||
expect(timeout.$('.val').getText()).toEqual('0'); | ||
|
||
browser.ignoreSynchronization = true; | ||
|
||
timeout.$('.action').click(); | ||
timeout.$('.cancel').click(); | ||
|
||
browser.ignoreSynchronization = false; | ||
|
||
// whenStable should be called since the async action is cancelled. The | ||
// count should still be 0; | ||
expect(timeout.$('.val').getText()).toEqual('0'); | ||
}); | ||
|
||
it('should wait for a series of asynchronous actions', function() { | ||
var timeout = $('#multiDelayedIncrements'); | ||
|
||
// At this point, the async action is still pending, so the count should | ||
// still be 0. | ||
expect(timeout.$('.val').getText()).toEqual('0'); | ||
|
||
timeout.$('.action').click(); | ||
|
||
expect(timeout.$('.val').getText()).toEqual('10'); | ||
}); | ||
}); |