chore: fix build failure

This commit is contained in:
Satyajit Sahoo
2020-01-29 12:13:37 +01:00
parent 4bc0c8f66f
commit ea66b1a3b8

View File

@@ -1,33 +1,11 @@
import MockRouter from '../../../core/src/__tests__/__fixtures__/MockRouter';
import Screen from '../../../core/src/Screen';
import * as React from 'react';
import {
NavigationContainer,
NavigationContainerRef,
useNavigationBuilder,
} from '@react-navigation/core';
import { NavigationContainerRef } from '@react-navigation/core';
import { render } from 'react-native-testing-library';
import useLinking from '../useLinking';
it('throws if multiple instances of useLinking are used', () => {
const TestNavigator = (props: any) => {
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
return descriptors[state.routes[state.index].key].render();
};
const ref = React.createRef<NavigationContainerRef>();
const element = (
<NavigationContainer ref={ref}>
<TestNavigator initialRouteName="foo">
<Screen name="foo" component={() => null} />
</TestNavigator>
</NavigationContainer>
);
render(element);
const options = { prefixes: [] };
function Sample() {
@@ -36,19 +14,40 @@ it('throws if multiple instances of useLinking are used', () => {
return null;
}
const wrapper = <Sample />;
let element;
let component;
expect(() => (component = render(wrapper))).toThrowError(
"Looks like you are using 'useLinking' in multiple components. This is likely an error since deep links need to be handled only once."
expect(() => (element = render(<Sample />))).toThrowError(
"Looks like you are using 'useLinking' in multiple components."
);
if (component) {
// @ts-ignore
component.unmount();
// @ts-ignore
element?.unmount();
function A() {
useLinking(ref, options);
return null;
}
function B() {
useLinking(ref, options);
return null;
}
expect(
() =>
(element = render(
<>
<A />
<B />
</>
))
).toThrowError(
"Looks like you are using 'useLinking' in multiple components."
);
// @ts-ignore
element?.unmount();
function Sample2() {
useLinking(ref, options);
return null;