@@ -47,8 +47,6 @@ vi.mock('../utils/cache/store', () => {
47
47
vi . mock ( '@react-native-community/netinfo' , ( ) => {
48
48
return { NetInfoState : { } , addEventListener : vi . fn ( ) } ;
49
49
} ) ;
50
-
51
- let isNetInfoAvailable = false ;
52
50
let isAsyncStorageAvailable = true ;
53
51
54
52
await vi . hoisted ( async ( ) => {
@@ -61,36 +59,28 @@ async function mockRequireNetInfo() {
61
59
62
60
M . _load_original = M . _load ;
63
61
M . _load = ( uri : string , parent : string ) => {
64
- if ( uri === '@react-native-community/netinfo' ) {
65
- if ( isNetInfoAvailable ) return { } ;
66
- throw new Error ( "Module not found: @react-native-community/netinfo" ) ;
67
- }
68
62
if ( uri === '@react-native-async-storage/async-storage' ) {
69
63
if ( isAsyncStorageAvailable ) return { } ;
70
64
throw new Error ( "Module not found: @react-native-async-storage/async-storage" ) ;
71
65
}
72
-
73
66
return M . _load_original ( uri , parent ) ;
74
67
} ;
75
68
}
76
69
77
70
import { createForwardingEventProcessor , createBatchEventProcessor } from './event_processor_factory.react_native' ;
78
71
import { getForwardingEventProcessor } from './forwarding_event_processor' ;
79
72
import defaultEventDispatcher from './event_dispatcher/default_dispatcher.browser' ;
80
- import { EVENT_STORE_PREFIX , extractEventProcessor , FAILED_EVENT_RETRY_INTERVAL , getPrefixEventStore } from './event_processor_factory' ;
73
+ import { EVENT_STORE_PREFIX , extractEventProcessor , FAILED_EVENT_RETRY_INTERVAL } from './event_processor_factory' ;
81
74
import { getOpaqueBatchEventProcessor } from './event_processor_factory' ;
82
75
import { AsyncStore , AsyncPrefixStore , SyncStore , SyncPrefixStore } from '../utils/cache/store' ;
83
76
import { AsyncStorageCache } from '../utils/cache/async_storage_cache.react_native' ;
84
- import { ReactNativeNetInfoEventProcessor } from './batch_event_processor.react_native' ;
85
- import { BatchEventProcessor } from './batch_event_processor' ;
86
77
import { MODULE_NOT_FOUND_REACT_NATIVE_ASYNC_STORAGE } from '../utils/import.react_native/@react-native-async-storage/async-storage' ;
87
78
88
79
describe ( 'createForwardingEventProcessor' , ( ) => {
89
80
const mockGetForwardingEventProcessor = vi . mocked ( getForwardingEventProcessor ) ;
90
81
91
82
beforeEach ( ( ) => {
92
83
mockGetForwardingEventProcessor . mockClear ( ) ;
93
- isNetInfoAvailable = false ;
94
84
} ) ;
95
85
96
86
it ( 'returns forwarding event processor by calling getForwardingEventProcessor with the provided dispatcher' , ( ) => {
@@ -119,27 +109,12 @@ describe('createBatchEventProcessor', () => {
119
109
const MockAsyncPrefixStore = vi . mocked ( AsyncPrefixStore ) ;
120
110
121
111
beforeEach ( ( ) => {
122
- isNetInfoAvailable = false ;
123
112
mockGetOpaqueBatchEventProcessor . mockClear ( ) ;
124
113
MockAsyncStorageCache . mockClear ( ) ;
125
114
MockSyncPrefixStore . mockClear ( ) ;
126
115
MockAsyncPrefixStore . mockClear ( ) ;
127
116
} ) ;
128
117
129
- it ( 'returns an instance of ReacNativeNetInfoEventProcessor if netinfo can be required' , async ( ) => {
130
- isNetInfoAvailable = true ;
131
- const processor = createBatchEventProcessor ( { } ) ;
132
- expect ( Object . is ( processor , mockGetOpaqueBatchEventProcessor . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
133
- expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 1 ] ) . toBe ( ReactNativeNetInfoEventProcessor ) ;
134
- } ) ;
135
-
136
- it ( 'returns an instance of BatchEventProcessor if netinfo cannot be required' , async ( ) => {
137
- isNetInfoAvailable = false ;
138
- const processor = createBatchEventProcessor ( { } ) ;
139
- expect ( Object . is ( processor , mockGetOpaqueBatchEventProcessor . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
140
- expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 1 ] ) . toBe ( BatchEventProcessor ) ;
141
- } ) ;
142
-
143
118
it ( 'uses AsyncStorageCache and AsyncPrefixStore to create eventStore if no eventStore is provided' , ( ) => {
144
119
const processor = createBatchEventProcessor ( { } ) ;
145
120
0 commit comments