Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 2efbbec

Browse files
committed
Fix e2e tests for tic-tac-toe
1 parent eef316e commit 2efbbec

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

tests/protractor/tictactoe/tictactoe.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var app = angular.module('tictactoe', ['firebase']);
22
app.controller('TicTacToeCtrl', function Chat($scope, $firebaseObject) {
3+
$scope.board = {};
34
// Get a reference to the Firebase
45
var boardRef = new Firebase('https://angularfire.firebaseio-demo.com/tictactoe');
56

tests/protractor/tictactoe/tictactoe.spec.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)