Skip to content

Commit 9234066

Browse files
committed
attempt to reproduce #8286
1 parent e480aaa commit 9234066

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

FirebaseDatabase/Tests/Integration/FIRDatabaseQueryTests.m

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import "FirebaseDatabase/Tests/Integration/FIRDatabaseQueryTests.h"
18-
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
18+
//#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h" doesn't work with swift?
1919
#import "FirebaseDatabase/Sources/Api/Private/FIRDatabaseQuery_Private.h"
2020
#import "FirebaseDatabase/Sources/Constants/FConstants.h"
2121
#import "FirebaseDatabase/Sources/Core/FQuerySpec.h"
@@ -4468,4 +4468,67 @@ - (void)testGetSkipsPersistenceCacheWhenOnline {
44684468
WAIT_FOR(done);
44694469
}
44704470

4471+
- (void)testGetTriggersListener {
4472+
FIRDatabase* db = [self databaseForURL:self.databaseURL name:@"fir-multi-shards"];
4473+
4474+
FIRDatabaseReference* ref = [db referenceWithPath:@"james"];
4475+
FIRDatabaseReference* children = [ref child:@"children"];
4476+
4477+
__block BOOL done = NO;
4478+
4479+
[children removeValueWithCompletionBlock:^(NSError* _Nullable error,
4480+
FIRDatabaseReference* _Nonnull ref) {
4481+
XCTAssertNil(error);
4482+
done = YES;
4483+
}];
4484+
4485+
WAIT_FOR(done);
4486+
done = NO;
4487+
4488+
[[children childByAutoId] setValue:@{@"name" : @1}
4489+
withCompletionBlock:^(NSError* error, FIRDatabaseReference* ref) {
4490+
XCTAssertNil(error);
4491+
done = YES;
4492+
}];
4493+
4494+
WAIT_FOR(done);
4495+
done = NO;
4496+
4497+
[[children childByAutoId] setValue:@{@"name" : @2}
4498+
withCompletionBlock:^(NSError* error, FIRDatabaseReference* ref) {
4499+
XCTAssertNil(error);
4500+
done = YES;
4501+
}];
4502+
4503+
WAIT_FOR(done);
4504+
done = NO;
4505+
4506+
__block BOOL nextDone = NO;
4507+
4508+
[children observeEventType:FIRDataEventTypeValue
4509+
withBlock:^(FIRDataSnapshot* snapshot) {
4510+
if (done == YES) {
4511+
XCTAssertTrue(snapshot.childrenCount == 2U);
4512+
nextDone = YES;
4513+
return;
4514+
}
4515+
XCTAssertTrue(snapshot.childrenCount == 2U);
4516+
done = YES;
4517+
}];
4518+
4519+
WAIT_FOR(done);
4520+
4521+
__block BOOL getDone = NO;
4522+
4523+
[[[children queryOrderedByChild:@"name"] queryEqualToValue:@2]
4524+
getDataWithCompletionBlock:^(NSError* _Nullable error, FIRDataSnapshot* _Nonnull snapshot) {
4525+
XCTAssertNil(error);
4526+
XCTAssertTrue([snapshot exists]);
4527+
getDone = YES;
4528+
}];
4529+
4530+
WAIT_FOR(getDone);
4531+
// WAIT_FOR(nextDone); // when uncommented, test times out.
4532+
}
4533+
44714534
@end

0 commit comments

Comments
 (0)