From ca737359dbbcba511d77137f1271ef0b751b581a Mon Sep 17 00:00:00 2001 From: themiswang Date: Thu, 14 Mar 2024 14:05:44 -0400 Subject: [PATCH] fix unit tests (#12553) --- .../Tests/Unit/RCNRemoteConfigTest.m | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m index e02b8ecaabf..38cef18cdb3 100644 --- a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m +++ b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m @@ -1801,16 +1801,10 @@ - (void)testRealtimeStreamRequestBody { } - (void)testFetchAndActivateRolloutsNotifyInterop { - id mockNotificationCenter = [OCMockObject mockForClass:[NSNotificationCenter class]]; - [[mockNotificationCenter expect] postNotificationName:@"RolloutsStateDidChangeNotification" - object:[OCMArg any] - userInfo:[OCMArg any]]; - id mockSubscriber = [OCMockObject mockForProtocol:@protocol(FIRRolloutsStateSubscriber)]; - [[mockSubscriber expect] rolloutsStateDidChange:[OCMArg any]]; - - XCTestExpectation *expectation = [self - expectationWithDescription:[NSString - stringWithFormat:@"Test rollout update send notification"]]; + XCTestExpectation *notificationExpectation = + [self expectationForNotification:@"FIRRolloutsStateDidChangeNotification" + object:nil + handler:nil]; XCTAssertEqual(_configInstances[RCNTestRCInstanceDefault].lastFetchStatus, FIRRemoteConfigFetchStatusNoFetchYet); @@ -1826,15 +1820,12 @@ - (void)testFetchAndActivateRolloutsNotifyInterop { XCTAssertGreaterThan( self->_configInstances[RCNTestRCInstanceDefault].lastFetchTime.timeIntervalSince1970, 0, @"last fetch time interval should be set."); - [expectation fulfill]; + [notificationExpectation fulfill]; }; [_configInstances[RCNTestRCInstanceDefault] fetchAndActivateWithCompletionHandler:fetchAndActivateCompletion]; - [self waitForExpectationsWithTimeout:_expectationTimeout - handler:^(NSError *error) { - XCTAssertNil(error); - }]; + [self waitForExpectations:@[ notificationExpectation ] timeout:_expectationTimeout]; } #pragma mark - Test Helpers