@@ -15,10 +15,13 @@ describe('TicTacToe App', function () {
1515 var flow = protractor . promise . controlFlow ( ) ;
1616
1717 function waitOne ( ) {
18- return protractor . promise . delayed ( 500 ) ;
18+ return protractor . promise . delayed ( 1500 ) ;
1919 }
2020
2121 function sleep ( ) {
22+ // flow.execute takes a function and if the
23+ // function returns a promise it waits for it
24+ // to be resolved
2225 flow . execute ( waitOne ) ;
2326 }
2427
@@ -65,22 +68,19 @@ describe('TicTacToe App', function () {
6568 $ ( '#resetRef' ) . click ( ) ;
6669
6770 // Wait for the board to reset
68- browser . sleep ( ) . then ( function ( ) {
69- // Make sure the board has 9 cells
71+ sleep ( ) ;
7072
71- var cells = element . all ( by . css ( '.cell' ) ) ;
72- expect ( cells . count ( ) ) . toBe ( 9 ) ;
73+ // Make sure the board has 9 cells
74+ var cells = element . all ( by . css ( '.cell' ) ) ;
75+ expect ( cells . count ( ) ) . toBe ( 9 ) ;
7376
74- // Make sure the board is empty
75- cells . each ( function ( element ) {
76- expect ( element . getText ( ) ) . toBe ( '' ) ;
77- } ) ;
77+ // Make sure the board is empty
78+ cells . each ( function ( element ) {
79+ expect ( element . getText ( ) ) . toBe ( '' ) ;
7880 } ) ;
7981 } ) ;
8082
8183 it ( 'updates the board when cells are clicked' , function ( ) {
82-
83- var cells = element . all ( by . css ( '.cell' ) ) ;
8484 // Make sure the board has 9 cells
8585 expect ( cells . count ( ) ) . toBe ( 9 ) ;
8686
@@ -89,20 +89,21 @@ describe('TicTacToe App', function () {
8989 cells . get ( 2 ) . click ( ) ;
9090 cells . get ( 6 ) . click ( ) ;
9191
92- browser . sleep ( ) . then ( function ( ) {
93- // Make sure the content of each clicked cell is correct
94- expect ( cells . get ( 0 ) . getText ( ) ) . toBe ( 'X' ) ;
95- expect ( cells . get ( 2 ) . getText ( ) ) . toBe ( 'O' ) ;
96- expect ( cells . get ( 6 ) . getText ( ) ) . toBe ( 'X' ) ;
97- } ) ;
92+ sleep ( ) ;
9893
94+ // Make sure the content of each clicked cell is correct
95+ expect ( cells . get ( 0 ) . getText ( ) ) . toBe ( 'X' ) ;
96+ expect ( cells . get ( 2 ) . getText ( ) ) . toBe ( 'O' ) ;
97+ expect ( cells . get ( 6 ) . getText ( ) ) . toBe ( 'X' ) ;
9998 } ) ;
10099
101100 it ( 'persists state across refresh' , function ( done ) {
102101 // Refresh the page, passing the push ID to use for data storage
103102 browser . get ( 'tictactoe/tictactoe.html?pushId=' + firebaseRef . key ( ) ) . then ( function ( ) {
104103 // Wait for AngularFire to sync the initial state
105104 sleep ( ) ;
105+ sleep ( ) ;
106+
106107 // Make sure the board has 9 cells
107108 expect ( cells . count ( ) ) . toBe ( 9 ) ;
108109
0 commit comments