1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import { FC , ForwardedRef } from 'react' ;
16+ import { FC } from 'react' ;
1717import React , { render } from '@testing-library/react' ;
1818
1919import useProvider from './helpers/hooks/useProvider' ;
2020
21- import { NavRef } from '../src/hooks/useNavigationTracker' ;
2221import { ATTRIBUTES } from '../src/utils/spanFactory' ;
2322import sinon from 'sinon' ;
2423import { NavigationTracker } from '../src' ;
2524
2625import { AppState } from 'react-native' ;
2726import api from '@opentelemetry/api' ;
28- import * as rnn from './helpers/react-navigation-native' ;
29- import { NavigationTrackerConfig } from '../src/types/navigation' ;
27+ import { TrackerConfig } from '../src/types/navigation' ;
28+
29+ const sandbox = sinon . createSandbox ( ) ;
30+
31+ const mockAddListener = sandbox . stub ( ) ;
32+ const mockGetCurrentRoute = sandbox . stub ( ) ;
3033
3134const AppWithProvider : FC < {
3235 shouldPassProvider : boolean ;
33- config ?: NavigationTrackerConfig ;
36+ config ?: TrackerConfig ;
3437} > = ( { shouldPassProvider, config } ) => {
35- const { useNavigationContainerRef } = rnn ;
36- const ref = useNavigationContainerRef ( ) ;
3738 const provider = useProvider ( ) ;
3839
3940 return (
4041 < NavigationTracker
41- ref = { ref as unknown as ForwardedRef < NavRef > }
42+ ref = { {
43+ current : {
44+ getCurrentRoute : mockGetCurrentRoute ,
45+ addListener : mockAddListener ,
46+ } ,
47+ } }
4248 config = { config }
4349 provider = { shouldPassProvider ? provider . current : undefined }
4450 >
@@ -48,11 +54,6 @@ const AppWithProvider: FC<{
4854} ;
4955
5056describe ( 'NavigationTracker.tsx' , function ( ) {
51- const sandbox = sinon . createSandbox ( ) ;
52-
53- const mockAddListener = sandbox . stub ( ) ;
54- const mockGetCurrentRoute = sandbox . stub ( ) ;
55-
5657 let mockAddEventListener : sinon . SinonSpy ;
5758 let mockConsoleDir : sinon . SinonSpy ;
5859 let mockConsoleInfo : sinon . SinonSpy ;
@@ -61,16 +62,6 @@ describe('NavigationTracker.tsx', function () {
6162 let mockGlobalTracer : sinon . SinonSpy ;
6263
6364 beforeEach ( function ( ) {
64- sandbox . stub ( rnn , 'useNavigationContainerRef' ) . callsFake (
65- ( ) =>
66- ( {
67- current : {
68- getCurrentRoute : mockGetCurrentRoute ,
69- addListener : mockAddListener ,
70- } ,
71- } as unknown as ReturnType < typeof rnn . useNavigationContainerRef > )
72- ) ;
73-
7465 mockAddEventListener = sandbox . spy ( AppState , 'addEventListener' ) ;
7566 mockConsoleDir = sandbox . spy ( console , 'dir' ) ;
7667 mockConsoleInfo = sandbox . spy ( console , 'info' ) ;
0 commit comments