Skip to content

Commit

Permalink
Fix lint/prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Mar 30, 2023
1 parent bd6c6e9 commit c9ac0e3
Showing 1 changed file with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,9 @@ describe('ReactFabric', () => {
'\n in RCTView (at **)' +
'\n in ContainsStrictModeChild (at **)',
]);
expect(match).toBe(ReactNativePrivateInterface.getNativeTagFromPublicInstance(child));
expect(match).toBe(
ReactNativePrivateInterface.getNativeTagFromPublicInstance(child),
);
});

it('findNodeHandle should warn if passed a component that is inside StrictMode', async () => {
Expand Down Expand Up @@ -969,7 +971,9 @@ describe('ReactFabric', () => {
'\n in RCTView (at **)' +
'\n in IsInStrictMode (at **)',
]);
expect(match).toBe(ReactNativePrivateInterface.getNativeTagFromPublicInstance(child));
expect(match).toBe(
ReactNativePrivateInterface.getNativeTagFromPublicInstance(child),
);
});

it('should no-op if calling sendAccessibilityEvent on unmounted refs', async () => {
Expand Down Expand Up @@ -1010,27 +1014,21 @@ describe('ReactFabric', () => {
uiViewClassName: 'RCTView',
}));

let viewRef;
await act(() => {
ReactFabric.render(
<View
foo="test"
ref={ref => {
viewRef = ref;
}}
/>,
1,
);
ReactFabric.render(<View foo="test" />, 1);
});

const internalInstanceHandle = nativeFabricUIManager.createNode.mock.calls[0][4];
const internalInstanceHandle =
nativeFabricUIManager.createNode.mock.calls[0][4];
expect(internalInstanceHandle).toEqual(expect.any(Object));

const expectedShadowNode =
nativeFabricUIManager.createNode.mock.results[0].value;
expect(expectedShadowNode).toEqual(expect.any(Object));

const node = ReactFabric.getNodeFromInternalInstanceHandle(internalInstanceHandle);
const node = ReactFabric.getNodeFromInternalInstanceHandle(
internalInstanceHandle,
);
expect(node).toBe(expectedShadowNode);
});

Expand All @@ -1053,10 +1051,14 @@ describe('ReactFabric', () => {
);
});

const internalInstanceHandle = nativeFabricUIManager.createNode.mock.calls[0][4];
const internalInstanceHandle =
nativeFabricUIManager.createNode.mock.calls[0][4];
expect(internalInstanceHandle).toEqual(expect.any(Object));

const publicInstance = ReactFabric.getPublicInstanceFromInternalInstanceHandle(internalInstanceHandle);
const publicInstance =
ReactFabric.getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle,
);
expect(publicInstance).toBe(viewRef);
});

Expand All @@ -1069,26 +1071,35 @@ describe('ReactFabric', () => {
}));

await act(() => {
ReactFabric.render(
<RCTText>Text content</RCTText>,
1,
);
ReactFabric.render(<RCTText>Text content</RCTText>, 1);
});

// Access the internal instance handle used to create the text node.
const internalInstanceHandle = nativeFabricUIManager.createNode.mock.calls[0][4];
const internalInstanceHandle =
nativeFabricUIManager.createNode.mock.calls[0][4];
expect(internalInstanceHandle).toEqual(expect.any(Object));

// Text public instances should be created lazily.
expect(ReactNativePrivateInterface.createPublicTextInstance).not.toHaveBeenCalled();
expect(
ReactNativePrivateInterface.createPublicTextInstance,
).not.toHaveBeenCalled();

const publicInstance = ReactFabric.getPublicInstanceFromInternalInstanceHandle(internalInstanceHandle);
const publicInstance =
ReactFabric.getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle,
);

// We just requested the text public instance, so it should have been created at this point.
expect(ReactNativePrivateInterface.createPublicTextInstance).toHaveBeenCalledTimes(1);
expect(ReactNativePrivateInterface.createPublicTextInstance).toHaveBeenCalledWith(internalInstanceHandle);
expect(
ReactNativePrivateInterface.createPublicTextInstance,
).toHaveBeenCalledTimes(1);
expect(
ReactNativePrivateInterface.createPublicTextInstance,
).toHaveBeenCalledWith(internalInstanceHandle);

const expectedPublicInstance = ReactNativePrivateInterface.createPublicTextInstance.mock.results[0].value;
const expectedPublicInstance =
ReactNativePrivateInterface.createPublicTextInstance.mock.results[0]
.value;
expect(publicInstance).toBe(expectedPublicInstance);
});
});

0 comments on commit c9ac0e3

Please sign in to comment.