|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | #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? |
19 | 19 | #import "FirebaseDatabase/Sources/Api/Private/FIRDatabaseQuery_Private.h"
|
20 | 20 | #import "FirebaseDatabase/Sources/Constants/FConstants.h"
|
21 | 21 | #import "FirebaseDatabase/Sources/Core/FQuerySpec.h"
|
@@ -4468,4 +4468,67 @@ - (void)testGetSkipsPersistenceCacheWhenOnline {
|
4468 | 4468 | WAIT_FOR(done);
|
4469 | 4469 | }
|
4470 | 4470 |
|
| 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 | + |
4471 | 4534 | @end
|
0 commit comments