Skip to content

Commit 0f688dc

Browse files
philIipfacebook-github-bot
authored andcommitted
test runtime lifecycle callback (facebook#37897)
Summary: Pull Request resolved: facebook#37897 Changelog: [Internal] adding unit test for `instance:didInitializeRuntime` Reviewed By: cipolleschi Differential Revision: D46704036 fbshipit-source-id: 6418bae56ae465f6ed9addde75d4de5719f402bb
1 parent 066d52b commit 0f688dc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/react-native/ReactCommon/react/bridgeless/iostests/RCTHostTests.mm

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,25 @@ - (void)testDidReceiveErrorStack
134134
stackFrame0[@"file"] = @"file2.js";
135135
[stack addObject:stackFrame1];
136136

137-
[instanceDelegate instance:OCMClassMock([RCTInstance class])
138-
didReceiveJSErrorStack:stack
139-
message:@"message"
140-
exceptionId:5
141-
isFatal:YES];
137+
[instanceDelegate instance:[OCMArg any] didReceiveJSErrorStack:stack message:@"message" exceptionId:5 isFatal:YES];
142138

143139
OCMVerify(
144140
OCMTimes(1),
145141
[_mockHostDelegate host:_subject didReceiveJSErrorStack:stack message:@"message" exceptionId:5 isFatal:YES]);
146142
}
147143

144+
- (void)testDidInitializeRuntime
145+
{
146+
id<RCTHostRuntimeDelegate> mockRuntimeDelegate = OCMProtocolMock(@protocol(RCTHostRuntimeDelegate));
147+
_subject.runtimeDelegate = mockRuntimeDelegate;
148+
149+
auto hermesRuntime = facebook::hermes::makeHermesRuntime();
150+
facebook::jsi::Runtime *rt = hermesRuntime.get();
151+
152+
id<RCTInstanceDelegate> instanceDelegate = (id<RCTInstanceDelegate>)_subject;
153+
[instanceDelegate instance:[OCMArg any] didInitializeRuntime:*rt];
154+
155+
OCMVerify(OCMTimes(1), [mockRuntimeDelegate host:_subject didInitializeRuntime:*rt]);
156+
}
157+
148158
@end

0 commit comments

Comments
 (0)