Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 30 additions & 36 deletions FirebaseDatabase/Tests/Integration/FEventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,42 +362,36 @@ - (void)testOnceValueFiresExactlyOnce {
}

- (void)testOnceChildAddedFiresExactlyOnce {
__block int badCount = 0;

// for(int i = 0; i < 100; i++) {

FIRDatabaseReference* path = [FTestHelpers getRandomNode];
__block BOOL firstCall = YES;

__block BOOL done = NO;

[path observeSingleEventOfType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot* snapshot) {
XCTAssertTrue(firstCall, @"Properly saw first call");
firstCall = NO;
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw node value");
XCTAssertEqualObjects(@"foo", [snapshot key],
@"Properly saw the first node");
if (![[snapshot value] isEqual:@42]) {
exit(-1);
badCount = badCount + 1;
}

done = YES;
}];

[[path child:@"foo"] setValue:@42];
[[path child:@"bar"] setValue:@84]; // XXX FIXME sometimes this event fires first
[[path child:@"foo"] setValue:@168];

// [path setValue:nil withCompletionBlock:^(BOOL status) { done = YES; }];
[self waitUntil:^BOOL {
return done;
}];

// }

NSLog(@"BADCOUNT: %d", badCount);
for(int i = 0; i < 100; i++) {

FIRDatabaseReference* path = [FTestHelpers getRandomNode];
__block BOOL firstCall = YES;

__block BOOL done = NO;

[path observeSingleEventOfType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot* snapshot) {
XCTAssertTrue(firstCall, @"Properly saw first call");
firstCall = NO;
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw node value");
XCTAssertEqualObjects(@"foo", [snapshot key],
@"Properly saw the first node");
if (![[snapshot value] isEqual:@42]) {
exit(-1);
}

done = YES;
}];

[[path child:@"foo"] setValue:@42];
[[path child:@"bar"] setValue:@84]; // XXX FIXME sometimes this event fires first
[[path child:@"foo"] setValue:@168];

// [path setValue:nil withCompletionBlock:^(BOOL status) { done = YES; }];
[self waitUntil:^BOOL {
return done;
}];
}
}

- (void)testOnceValueFiresExactlyOnceEvenIfThereIsASetInsideCallback {
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_database_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

set -euo pipefail

VERSION='4.7.2'
VERSION='4.12.0'
FILENAME="firebase-database-emulator-v${VERSION}.jar"
URL="https://storage.googleapis.com/firebase-preview-drop/emulator/${FILENAME}"

Expand Down
Loading