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

Commit 83399f8

Browse files
committed
chat.js,chat.spec.js: removed superfluous transaction code
1 parent 5935f84 commit 83399f8

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

tests/protractor/chat/chat.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<em>{{ message.from }}: </em>
3030
<span class="content">{{ message.content }}</span>
3131
</div>
32-
Message Count: <span id="messagesCount">{{ chat.numMessages ? chat.numMessages : 0 }}</span>
3332
</div>
3433

3534
<!-- Add message form -->

tests/protractor/chat/chat.spec.js

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ describe('Chat App', function () {
1111
// Reference to the messages repeater
1212
var messages = element.all(by.repeater('message in messages'));
1313

14-
// Reference to messages count
15-
var messagesCount = element(by.id('messagesCount'));
16-
1714
var flow = protractor.promise.controlFlow();
1815

1916
function waitOne() {
@@ -58,7 +55,6 @@ describe('Chat App', function () {
5855

5956
it('starts with an empty list of messages', function () {
6057
expect(messages.count()).toBe(0);
61-
expect(messagesCount.getText()).toEqual('0');
6258
});
6359

6460
it('adds new messages', function () {
@@ -72,9 +68,6 @@ describe('Chat App', function () {
7268

7369
// We should only have two messages in the repeater since we did a limit query
7470
expect(messages.count()).toBe(2);
75-
76-
// Messages count should include all messages, not just the ones displayed
77-
expect(messagesCount.getText()).toEqual('3');
7871
});
7972

8073
it('updates upon new remote messages', function () {
@@ -84,27 +77,15 @@ describe('Chat App', function () {
8477
firebaseRef.child("messages").push({
8578
from: 'Guest 2000',
8679
content: 'Remote message detected'
87-
}, function() {
88-
// Update the message count as well
89-
firebaseRef.child("numMessages").transaction(function(currentCount) {
90-
if (!currentCount) {
91-
return 1;
92-
} else {
93-
return currentCount + 1;
94-
}
95-
}, function (e, c, s) {
96-
if( e ) { def.reject(e); }
97-
else { def.fulfill(); }
98-
});
80+
}, function(err) {
81+
if( err ) { def.reject(err); }
82+
else { def.fulfill(); }
9983
});
10084
return def.promise;
10185
});
10286

10387
// We should only have two messages in the repeater since we did a limit query
10488
expect(messages.count()).toBe(2);
105-
106-
// Messages count should include all messages, not just the ones displayed
107-
expect(messagesCount.getText()).toEqual('4');
10889
});
10990

11091
it('updates upon removed remote messages', function () {
@@ -113,27 +94,16 @@ describe('Chat App', function () {
11394
// Simulate a message being deleted remotely
11495
var onCallback = firebaseRef.child("messages").limitToLast(1).on("child_added", function(childSnapshot) {
11596
firebaseRef.child("messages").off("child_added", onCallback);
116-
childSnapshot.ref().remove(function() {
117-
firebaseRef.child("numMessages").transaction(function(currentCount) {
118-
if (!currentCount) {
119-
return 1;
120-
} else {
121-
return currentCount - 1;
122-
}
123-
}, function(err) {
124-
if( err ) { def.reject(err); }
125-
else { def.fulfill(); }
126-
});
97+
childSnapshot.ref().remove(function(err) {
98+
if( err ) { def.reject(err); }
99+
else { def.fulfill(); }
127100
});
128101
});
129102
return def.promise;
130103
});
131104

132105
// We should only have two messages in the repeater since we did a limit query
133106
expect(messages.count()).toBe(2);
134-
135-
// Messages count should include all messages, not just the ones displayed
136-
expect(messagesCount.getText()).toEqual('3');
137107
});
138108

139109
it('stops updating once the AngularFire bindings are destroyed', function () {
@@ -143,6 +113,5 @@ describe('Chat App', function () {
143113
sleep();
144114

145115
expect(messages.count()).toBe(0);
146-
expect(messagesCount.getText()).toEqual('0');
147116
});
148117
});

0 commit comments

Comments
 (0)