11import { verifyNoBrowserErrors } from 'angular2/src/test_lib/e2e_util' ;
22
3- function whenStable ( rootSelector ) {
4- // TODO(hankduan): remove this call once Protractor implements it
5- return browser . executeAsyncScript ( 'var el = document.querySelector("' + rootSelector + '");' +
6- 'window.getAngularTestability(el).whenStable(arguments[0]);' ) ;
7- } ;
8-
93describe ( 'async' , ( ) => {
104 var URL = 'examples/src/async/index.html' ;
115
@@ -20,51 +14,48 @@ describe('async', () => {
2014
2115 it ( 'should wait for asynchronous actions' , ( ) => {
2216 var timeout = $ ( '#delayedIncrement' ) ;
23- timeout . $ ( '.action' ) . click ( ) ;
2417
2518 // At this point, the async action is still pending, so the count should
2619 // still be 0.
2720 expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '0' ) ;
2821
29- whenStable ( 'async-app' )
30- . then ( ( ) => {
31- // whenStable should only be called when the async action finished,
32- // so the count should be 1 at this point.
33- expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '1' ) ;
34- } ) ;
22+ timeout . $ ( '.action' ) . click ( ) ;
23+
24+ // whenStable should only be called when the async action finished,
25+ // so the count should be 1 at this point.
26+ expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '1' ) ;
3527 } ) ;
3628
3729 it ( 'should notice when asynchronous actions are cancelled' , ( ) => {
3830 var timeout = $ ( '#delayedIncrement' ) ;
39- timeout . $ ( '.action' ) . click ( ) ;
4031
4132 // At this point, the async action is still pending, so the count should
4233 // still be 0.
4334 expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '0' ) ;
4435
36+ browser . ignoreSynchronization = true ;
37+ timeout . $ ( '.action' ) . click ( ) ;
38+
4539 timeout . $ ( '.cancel' ) . click ( ) ;
46- whenStable ( 'async-app' )
47- . then ( ( ) => {
48- // whenStable should be called since the async action is cancelled. The
49- // count should still be 0;
50- expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '0' ) ;
51- } ) ;
40+ browser . ignoreSynchronization = false ;
41+
42+ // whenStable should be called since the async action is cancelled. The
43+ // count should still be 0;
44+ expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '0' ) ;
5245 } ) ;
5346
5447 it ( 'should wait for a series of asynchronous actions' , ( ) => {
5548 var timeout = $ ( '#multiDelayedIncrements' ) ;
56- timeout . $ ( '.action' ) . click ( ) ;
5749
5850 // At this point, the async action is still pending, so the count should
5951 // still be 0.
6052 expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '0' ) ;
6153
62- whenStable ( 'async-app' )
63- . then ( ( ) => {
64- // whenStable should only be called when all the async actions
65- // finished, so the count should be 10 at this point.
66- expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '10' ) ;
67- } ) ;
54+ timeout . $ ( '.action' ) . click ( ) ;
55+
56+ // whenStable should only be called when all the async actions
57+ // finished, so the count should be 10 at this point.
58+ expect ( timeout . $ ( '.val' ) . getText ( ) ) . toEqual ( '10' ) ;
6859 } ) ;
6960
7061 afterEach ( verifyNoBrowserErrors ) ;
0 commit comments