Skip to content

Commit

Permalink
add a unit test for rollout
Browse files Browse the repository at this point in the history
(cherry picked from commit 91d2b401f8415772ca89615b262c310faedf3160)
  • Loading branch information
ddnan committed Jan 30, 2024
1 parent cbd8ddb commit 6084dbd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,41 @@ - (void)testRealtimeStreamRequestBody {
XCTAssertTrue([strData containsString:@"appInstanceId:'iid'"]);
}

- (void)testFetchAndActivateRolloutsNotifyInterop {
id mockNotificationCenter = [OCMockObject mockForClass:[NSNotificationCenter class]];
[[mockNotificationCenter expect] postNotificationName:@"RolloutsStateDidChangeNotification"
object:[OCMArg any]
userInfo:[OCMArg any]];

XCTestExpectation *expectation = [self
expectationWithDescription:[NSString
stringWithFormat:@"Test rollout update send notification"]];

XCTAssertEqual(_configInstances[RCNTestRCInstanceDefault].lastFetchStatus,
FIRRemoteConfigFetchStatusNoFetchYet);

FIRRemoteConfigFetchAndActivateCompletion fetchAndActivateCompletion =
^void(FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
XCTAssertEqual(status, FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote);
XCTAssertNil(error);

XCTAssertEqual(self->_configInstances[RCNTestRCInstanceDefault].lastFetchStatus,
FIRRemoteConfigFetchStatusSuccess);
XCTAssertNotNil(self->_configInstances[RCNTestRCInstanceDefault].lastFetchTime);
XCTAssertGreaterThan(
self->_configInstances[RCNTestRCInstanceDefault].lastFetchTime.timeIntervalSince1970, 0,
@"last fetch time interval should be set.");
[expectation fulfill];
};

[_configInstances[RCNTestRCInstanceDefault]
fetchAndActivateWithCompletionHandler:fetchAndActivateCompletion];
[self waitForExpectationsWithTimeout:_expectationTimeout
handler:^(NSError *error) {
XCTAssertNil(error);
}];
}

#pragma mark - Test Helpers

- (FIROptions *)firstAppOptions {
Expand Down

0 comments on commit 6084dbd

Please sign in to comment.