Skip to content

Commit

Permalink
test runtime lifecycle callback
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

adding unit test for `instance:didInitializeRuntime`

Reviewed By: cipolleschi

Differential Revision: D46704036

fbshipit-source-id: 236820064eb13fba32fbbff41f3119d22a4bc172
  • Loading branch information
philIip authored and facebook-github-bot committed Jun 14, 2023
1 parent 09070f5 commit ad89e66
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 ad89e66

Please sign in to comment.