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 8
8
*
9
9
* @flow
10
10
*/
11
+ const uuidv4 = require ( 'uuid/v4' ) ;
11
12
12
13
import CoreManager from './CoreManager' ;
13
14
import canBeSerialized from './canBeSerialized' ;
@@ -64,8 +65,6 @@ const DEFAULT_BATCH_SIZE = 20;
64
65
// server with appropriate subclasses of ParseObject
65
66
const classMap = { } ;
66
67
67
- // Global counter for generating unique local Ids
68
- let localCount = 0 ;
69
68
// Global counter for generating unique Ids for non-single-instance objects
70
69
let objectCount = 0 ;
71
70
// On web clients, objects are single-instance: any two objects with the same Id
@@ -188,7 +187,7 @@ class ParseObject {
188
187
if ( typeof this . _localId === 'string' ) {
189
188
return this . _localId ;
190
189
}
191
- const localId = 'local' + String ( localCount ++ ) ;
190
+ const localId = 'local' + uuidv4 ( ) ;
192
191
this . _localId = localId ;
193
192
return localId ;
194
193
}
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ jest.dontMock('../unsavedChildren');
32
32
jest . dontMock ( '../ParseACL' ) ;
33
33
jest . dontMock ( '../LocalDatastore' ) ;
34
34
35
+ jest . mock ( 'uuid/v4' , ( ) => {
36
+ let value = 0 ;
37
+ return ( ) => value ++ ;
38
+ } ) ;
35
39
jest . dontMock ( './test_helpers/mockXHR' ) ;
36
40
37
41
jest . useFakeTimers ( ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ jest.dontMock('../LocalDatastore');
21
21
jest . dontMock ( '../OfflineQuery' ) ;
22
22
jest . dontMock ( '../LiveQuerySubscription' ) ;
23
23
24
+ jest . mock ( 'uuid/v4' , ( ) => {
25
+ let value = 0 ;
26
+ return ( ) => value ++ ;
27
+ } ) ;
24
28
const mockObject = function ( className ) {
25
29
this . className = className ;
26
30
this . attributes = { } ;
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ jest.dontMock('../TaskQueue');
27
27
jest . dontMock ( '../unique' ) ;
28
28
jest . dontMock ( '../UniqueInstanceStateController' ) ;
29
29
30
+ jest . mock ( 'uuid/v4' , ( ) => {
31
+ let value = 0 ;
32
+ return ( ) => value ++ ;
33
+ } ) ;
30
34
jest . dontMock ( './test_helpers/mockXHR' ) ;
31
35
32
36
const CoreManager = require ( '../CoreManager' ) ;
You can’t perform that action at this time.
0 commit comments