File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @jest -environment node
3+ */
4+ import { fromValue } from 'wonka' ;
5+ import * as messengers from './utils' ;
6+
7+ const createNativeMessenger = jest . spyOn ( messengers , 'createNativeMessenger' ) ;
8+ const createBrowserMessenger = jest . spyOn ( messengers , 'createBrowserMessenger' ) ;
9+
10+ it ( 'returns forwarding exchange' , ( ) => {
11+ ( global as any ) . window = undefined ;
12+ const { devtoolsExchange } = require ( './exchange' ) ; // eslint-disable-line
13+ expect ( createNativeMessenger ) . toBeCalledTimes ( 0 ) ;
14+ expect ( createBrowserMessenger ) . toBeCalledTimes ( 0 ) ;
15+
16+ const value = fromValue ( 'Heloo' ) ;
17+ const forward = jest . fn ( ) ;
18+
19+ devtoolsExchange ( { forward } ) ( value ) ;
20+ expect ( forward ) . toBeCalledTimes ( 1 ) ;
21+ expect ( forward ) . toBeCalledWith ( value ) ;
22+ } ) ;
Original file line number Diff line number Diff line change @@ -143,8 +143,9 @@ const messageHandlers = {
143143} as const ;
144144
145145export const devtoolsExchange = ( ( ) : Exchange => {
146- const isNative = navigator ?. product === 'ReactNative' ;
147- const isSSR = ! isNative && typeof window === undefined ;
146+ const isNative =
147+ typeof navigator !== 'undefined' && navigator ?. product === 'ReactNative' ;
148+ const isSSR = ! isNative && typeof window === 'undefined' ;
148149
149150 // Prod or SSR
150151 if ( process . env . NODE_ENV === 'production' || isSSR ) {
You can’t perform that action at this time.
0 commit comments