File tree Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 88 *
99 * @flow
1010 */
11+ const uuidv4 = require ( 'uuid/v4' ) ;
1112
1213import CoreManager from './CoreManager' ;
1314import canBeSerialized from './canBeSerialized' ;
@@ -64,8 +65,6 @@ const DEFAULT_BATCH_SIZE = 20;
6465// server with appropriate subclasses of ParseObject
6566const classMap = { } ;
6667
67- // Global counter for generating unique local Ids
68- let localCount = 0 ;
6968// Global counter for generating unique Ids for non-single-instance objects
7069let objectCount = 0 ;
7170// On web clients, objects are single-instance: any two objects with the same Id
@@ -188,7 +187,7 @@ class ParseObject {
188187 if ( typeof this . _localId === 'string' ) {
189188 return this . _localId ;
190189 }
191- const localId = 'local' + String ( localCount ++ ) ;
190+ const localId = 'local' + uuidv4 ( ) ;
192191 this . _localId = localId ;
193192 return localId ;
194193 }
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ jest.dontMock('../unsavedChildren');
3232jest . dontMock ( '../ParseACL' ) ;
3333jest . dontMock ( '../LocalDatastore' ) ;
3434
35+ jest . mock ( 'uuid/v4' , ( ) => {
36+ let value = 0 ;
37+ return ( ) => value ++ ;
38+ } ) ;
3539jest . dontMock ( './test_helpers/mockXHR' ) ;
3640
3741jest . useFakeTimers ( ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ jest.dontMock('../LocalDatastore');
2121jest . dontMock ( '../OfflineQuery' ) ;
2222jest . dontMock ( '../LiveQuerySubscription' ) ;
2323
24+ jest . mock ( 'uuid/v4' , ( ) => {
25+ let value = 0 ;
26+ return ( ) => value ++ ;
27+ } ) ;
2428const mockObject = function ( className ) {
2529 this . className = className ;
2630 this . attributes = { } ;
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ jest.dontMock('../TaskQueue');
2727jest . dontMock ( '../unique' ) ;
2828jest . dontMock ( '../UniqueInstanceStateController' ) ;
2929
30+ jest . mock ( 'uuid/v4' , ( ) => {
31+ let value = 0 ;
32+ return ( ) => value ++ ;
33+ } ) ;
3034jest . dontMock ( './test_helpers/mockXHR' ) ;
3135
3236const CoreManager = require ( '../CoreManager' ) ;
You can’t perform that action at this time.
0 commit comments