1
1
/**
2
- * Copyright 2024, Optimizely
2
+ * Copyright 2024-2025 , Optimizely
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -40,8 +40,8 @@ vi.mock('../utils/cache/async_storage_cache.react_native', () => {
40
40
return { AsyncStorageCache : vi . fn ( ) } ;
41
41
} ) ;
42
42
43
- vi . mock ( '../utils/cache/cache ' , ( ) => {
44
- return { SyncPrefixCache : vi . fn ( ) , AsyncPrefixCache : vi . fn ( ) } ;
43
+ vi . mock ( '../utils/cache/store ' , ( ) => {
44
+ return { SyncPrefixStore : vi . fn ( ) , AsyncPrefixStore : vi . fn ( ) } ;
45
45
} ) ;
46
46
47
47
vi . mock ( '@react-native-community/netinfo' , ( ) => {
@@ -79,7 +79,7 @@ import { getForwardingEventProcessor } from './forwarding_event_processor';
79
79
import defaultEventDispatcher from './event_dispatcher/default_dispatcher.browser' ;
80
80
import { EVENT_STORE_PREFIX , extractEventProcessor , FAILED_EVENT_RETRY_INTERVAL , getPrefixEventStore } from './event_processor_factory' ;
81
81
import { getOpaqueBatchEventProcessor } from './event_processor_factory' ;
82
- import { AsyncCache , AsyncPrefixCache , SyncCache , SyncPrefixCache } from '../utils/cache/cache ' ;
82
+ import { AsyncStore , AsyncPrefixStore , SyncStore , SyncPrefixStore } from '../utils/cache/store ' ;
83
83
import { AsyncStorageCache } from '../utils/cache/async_storage_cache.react_native' ;
84
84
import { ReactNativeNetInfoEventProcessor } from './batch_event_processor.react_native' ;
85
85
import { BatchEventProcessor } from './batch_event_processor' ;
@@ -115,15 +115,15 @@ describe('createForwardingEventProcessor', () => {
115
115
describe ( 'createBatchEventProcessor' , ( ) => {
116
116
const mockGetOpaqueBatchEventProcessor = vi . mocked ( getOpaqueBatchEventProcessor ) ;
117
117
const MockAsyncStorageCache = vi . mocked ( AsyncStorageCache ) ;
118
- const MockSyncPrefixCache = vi . mocked ( SyncPrefixCache ) ;
119
- const MockAsyncPrefixCache = vi . mocked ( AsyncPrefixCache ) ;
118
+ const MockSyncPrefixStore = vi . mocked ( SyncPrefixStore ) ;
119
+ const MockAsyncPrefixStore = vi . mocked ( AsyncPrefixStore ) ;
120
120
121
121
beforeEach ( ( ) => {
122
122
isNetInfoAvailable = false ;
123
123
mockGetOpaqueBatchEventProcessor . mockClear ( ) ;
124
124
MockAsyncStorageCache . mockClear ( ) ;
125
- MockSyncPrefixCache . mockClear ( ) ;
126
- MockAsyncPrefixCache . mockClear ( ) ;
125
+ MockSyncPrefixStore . mockClear ( ) ;
126
+ MockAsyncPrefixStore . mockClear ( ) ;
127
127
} ) ;
128
128
129
129
it ( 'returns an instance of ReacNativeNetInfoEventProcessor if netinfo can be required' , async ( ) => {
@@ -140,14 +140,14 @@ describe('createBatchEventProcessor', () => {
140
140
expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 1 ] ) . toBe ( BatchEventProcessor ) ;
141
141
} ) ;
142
142
143
- it ( 'uses AsyncStorageCache and AsyncPrefixCache to create eventStore if no eventStore is provided' , ( ) => {
143
+ it ( 'uses AsyncStorageCache and AsyncPrefixStore to create eventStore if no eventStore is provided' , ( ) => {
144
144
const processor = createBatchEventProcessor ( { } ) ;
145
145
146
146
expect ( Object . is ( processor , mockGetOpaqueBatchEventProcessor . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
147
147
const eventStore = mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . eventStore ;
148
- expect ( Object . is ( eventStore , MockAsyncPrefixCache . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
148
+ expect ( Object . is ( eventStore , MockAsyncPrefixStore . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
149
149
150
- const [ cache , prefix , transformGet , transformSet ] = MockAsyncPrefixCache . mock . calls [ 0 ] ;
150
+ const [ cache , prefix , transformGet , transformSet ] = MockAsyncPrefixStore . mock . calls [ 0 ] ;
151
151
expect ( Object . is ( cache , MockAsyncStorageCache . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
152
152
expect ( prefix ) . toBe ( EVENT_STORE_PREFIX ) ;
153
153
@@ -177,7 +177,7 @@ describe('createBatchEventProcessor', () => {
177
177
isAsyncStorageAvailable = false ;
178
178
const eventStore = {
179
179
operation : 'sync' ,
180
- } as SyncCache < string > ;
180
+ } as SyncStore < string > ;
181
181
182
182
const { AsyncStorageCache } = await vi . importActual <
183
183
typeof import ( '../utils/cache/async_storage_cache.react_native' )
@@ -192,16 +192,16 @@ describe('createBatchEventProcessor', () => {
192
192
isAsyncStorageAvailable = true ;
193
193
} ) ;
194
194
195
- it ( 'wraps the provided eventStore in a SyncPrefixCache if a SyncCache is provided as eventStore' , ( ) => {
195
+ it ( 'wraps the provided eventStore in a SyncPrefixStore if a SyncCache is provided as eventStore' , ( ) => {
196
196
const eventStore = {
197
197
operation : 'sync' ,
198
- } as SyncCache < string > ;
198
+ } as SyncStore < string > ;
199
199
200
200
const processor = createBatchEventProcessor ( { eventStore } ) ;
201
201
expect ( Object . is ( processor , mockGetOpaqueBatchEventProcessor . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
202
202
203
- expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . eventStore ) . toBe ( MockSyncPrefixCache . mock . results [ 0 ] . value ) ;
204
- const [ cache , prefix , transformGet , transformSet ] = MockSyncPrefixCache . mock . calls [ 0 ] ;
203
+ expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . eventStore ) . toBe ( MockSyncPrefixStore . mock . results [ 0 ] . value ) ;
204
+ const [ cache , prefix , transformGet , transformSet ] = MockSyncPrefixStore . mock . calls [ 0 ] ;
205
205
206
206
expect ( cache ) . toBe ( eventStore ) ;
207
207
expect ( prefix ) . toBe ( EVENT_STORE_PREFIX ) ;
@@ -211,16 +211,16 @@ describe('createBatchEventProcessor', () => {
211
211
expect ( transformSet ( { value : 1 } ) ) . toBe ( '{"value":1}' ) ;
212
212
} ) ;
213
213
214
- it ( 'wraps the provided eventStore in a AsyncPrefixCache if a AsyncCache is provided as eventStore' , ( ) => {
214
+ it ( 'wraps the provided eventStore in a AsyncPrefixStore if a AsyncCache is provided as eventStore' , ( ) => {
215
215
const eventStore = {
216
216
operation : 'async' ,
217
- } as AsyncCache < string > ;
217
+ } as AsyncStore < string > ;
218
218
219
219
const processor = createBatchEventProcessor ( { eventStore } ) ;
220
220
expect ( Object . is ( processor , mockGetOpaqueBatchEventProcessor . mock . results [ 0 ] . value ) ) . toBe ( true ) ;
221
221
222
- expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . eventStore ) . toBe ( MockAsyncPrefixCache . mock . results [ 0 ] . value ) ;
223
- const [ cache , prefix , transformGet , transformSet ] = MockAsyncPrefixCache . mock . calls [ 0 ] ;
222
+ expect ( mockGetOpaqueBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . eventStore ) . toBe ( MockAsyncPrefixStore . mock . results [ 0 ] . value ) ;
223
+ const [ cache , prefix , transformGet , transformSet ] = MockAsyncPrefixStore . mock . calls [ 0 ] ;
224
224
225
225
expect ( cache ) . toBe ( eventStore ) ;
226
226
expect ( prefix ) . toBe ( EVENT_STORE_PREFIX ) ;
0 commit comments