From ad89e66fb75dd1092cf42aada0774dc83dcbef9f Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Wed, 14 Jun 2023 13:04:21 -0700 Subject: [PATCH] test runtime lifecycle callback Summary: Changelog: [Internal] adding unit test for `instance:didInitializeRuntime` Reviewed By: cipolleschi Differential Revision: D46704036 fbshipit-source-id: 236820064eb13fba32fbbff41f3119d22a4bc172 --- .../react/bridgeless/iostests/RCTHostTests.mm | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/react/bridgeless/iostests/RCTHostTests.mm b/packages/react-native/ReactCommon/react/bridgeless/iostests/RCTHostTests.mm index b3a7a1fb04e89e..606d2d9dabd1f1 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/iostests/RCTHostTests.mm +++ b/packages/react-native/ReactCommon/react/bridgeless/iostests/RCTHostTests.mm @@ -134,15 +134,25 @@ - (void)testDidReceiveErrorStack stackFrame0[@"file"] = @"file2.js"; [stack addObject:stackFrame1]; - [instanceDelegate instance:OCMClassMock([RCTInstance class]) - didReceiveJSErrorStack:stack - message:@"message" - exceptionId:5 - isFatal:YES]; + [instanceDelegate instance:[OCMArg any] didReceiveJSErrorStack:stack message:@"message" exceptionId:5 isFatal:YES]; OCMVerify( OCMTimes(1), [_mockHostDelegate host:_subject didReceiveJSErrorStack:stack message:@"message" exceptionId:5 isFatal:YES]); } +- (void)testDidInitializeRuntime +{ + id mockRuntimeDelegate = OCMProtocolMock(@protocol(RCTHostRuntimeDelegate)); + _subject.runtimeDelegate = mockRuntimeDelegate; + + auto hermesRuntime = facebook::hermes::makeHermesRuntime(); + facebook::jsi::Runtime *rt = hermesRuntime.get(); + + id instanceDelegate = (id)_subject; + [instanceDelegate instance:[OCMArg any] didInitializeRuntime:*rt]; + + OCMVerify(OCMTimes(1), [mockRuntimeDelegate host:_subject didInitializeRuntime:*rt]); +} + @end