@@ -65,19 +65,22 @@ describe('TicTacToe App', function () {
6565 $ ( '#resetRef' ) . click ( ) ;
6666
6767 // Wait for the board to reset
68- sleep ( ) ;
68+ browser . sleep ( ) . then ( function ( ) {
69+ // Make sure the board has 9 cells
6970
70- // Make sure the board has 9 cells
71- var cells = element . all ( by . css ( '.cell' ) ) ;
72- expect ( cells . count ( ) ) . toBe ( 9 ) ;
71+ var cells = element . all ( by . css ( '.cell' ) ) ;
72+ expect ( cells . count ( ) ) . toBe ( 9 ) ;
7373
74- // Make sure the board is empty
75- cells . each ( function ( element ) {
76- expect ( element . getText ( ) ) . toBe ( '' ) ;
74+ // Make sure the board is empty
75+ cells . each ( function ( element ) {
76+ expect ( element . getText ( ) ) . toBe ( '' ) ;
77+ } ) ;
7778 } ) ;
7879 } ) ;
7980
8081 it ( 'updates the board when cells are clicked' , function ( ) {
82+
83+ var cells = element . all ( by . css ( '.cell' ) ) ;
8184 // Make sure the board has 9 cells
8285 expect ( cells . count ( ) ) . toBe ( 9 ) ;
8386
@@ -86,20 +89,20 @@ describe('TicTacToe App', function () {
8689 cells . get ( 2 ) . click ( ) ;
8790 cells . get ( 6 ) . click ( ) ;
8891
89- sleep ( ) ;
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+ } ) ;
9098
91- // Make sure the content of each clicked cell is correct
92- expect ( cells . get ( 0 ) . getText ( ) ) . toBe ( 'X' ) ;
93- expect ( cells . get ( 2 ) . getText ( ) ) . toBe ( 'O' ) ;
94- expect ( cells . get ( 6 ) . getText ( ) ) . toBe ( 'X' ) ;
9599 } ) ;
96100
97101 it ( 'persists state across refresh' , function ( done ) {
98102 // Refresh the page, passing the push ID to use for data storage
99103 browser . get ( 'tictactoe/tictactoe.html?pushId=' + firebaseRef . key ( ) ) . then ( function ( ) {
100104 // Wait for AngularFire to sync the initial state
101- sleep ( 2000 ) ;
102-
105+ sleep ( ) ;
103106 // Make sure the board has 9 cells
104107 expect ( cells . count ( ) ) . toBe ( 9 ) ;
105108
0 commit comments