feat(testability): Expose function frameworkStabilizers

Closes #5485
This commit is contained in:
Hank Duan
2016-01-05 12:56:24 -08:00
parent 95248f46a1
commit 69ae3634c7
6 changed files with 159 additions and 8 deletions

View File

@ -58,5 +58,35 @@ describe('async', () => {
expect(timeout.$('.val').getText()).toEqual('10');
});
it('should wait via frameworkStabilizer', () => {
var whenAllStable = function() {
return browser.executeAsyncScript('window.frameworkStabilizers[0](arguments[0]);');
};
// This disables protractor's wait mechanism
browser.ignoreSynchronization = true;
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();
whenAllStable().then((didWork) => {
// whenAllStable should only be called when all the async actions
// finished, so the count should be 10 at this point.
expect(timeout.$('.val').getText()).toEqual('10');
expect(didWork).toBeTruthy(); // Work was done.
});
whenAllStable().then((didWork) => {
// whenAllStable should be called immediately since nothing is pending.
expect(didWork).toBeFalsy(); // No work was done.
browser.ignoreSynchronization = false;
});
});
afterEach(verifyNoBrowserErrors);
});