Skip to content

Commit

Permalink
test runtime lifecycle callback (#37897)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37897

Changelog: [Internal]

adding unit test for `instance:didInitializeRuntime`

Reviewed By: cipolleschi

Differential Revision: D46704036

fbshipit-source-id: 6418bae56ae465f6ed9addde75d4de5719f402bb
  • Loading branch information
philIip authored and facebook-github-bot committed Jun 15, 2023
1 parent 066d52b commit 0f688dc
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RCTHostRuntimeDelegate> mockRuntimeDelegate = OCMProtocolMock(@protocol(RCTHostRuntimeDelegate));
_subject.runtimeDelegate = mockRuntimeDelegate;

auto hermesRuntime = facebook::hermes::makeHermesRuntime();
facebook::jsi::Runtime *rt = hermesRuntime.get();

id<RCTInstanceDelegate> instanceDelegate = (id<RCTInstanceDelegate>)_subject;
[instanceDelegate instance:[OCMArg any] didInitializeRuntime:*rt];

OCMVerify(OCMTimes(1), [mockRuntimeDelegate host:_subject didInitializeRuntime:*rt]);
}

@end

0 comments on commit 0f688dc

Please sign in to comment.