@@ -16,11 +16,18 @@ jest.dontMock('../LocalDatastore');
1616jest . dontMock ( 'crypto-js/aes' ) ;
1717jest . setMock ( '../EventuallyQueue' , { poll : jest . fn ( ) } ) ;
1818
19+ global . indexedDB = require ( './test_helpers/mockIndexedDB' ) ;
1920const CoreManager = require ( '../CoreManager' ) ;
2021const EventuallyQueue = require ( '../EventuallyQueue' ) ;
21- const Parse = require ( '../Parse' ) ;
2222
2323describe ( 'Parse module' , ( ) => {
24+ let Parse ;
25+ beforeEach ( ( ) => {
26+ jest . isolateModules ( ( ) => {
27+ Parse = require ( '../Parse' ) ;
28+ } ) ;
29+ } ) ;
30+
2431 it ( 'can be initialized with keys' , ( ) => {
2532 Parse . initialize ( 'A' , 'B' ) ;
2633 expect ( CoreManager . get ( 'APPLICATION_ID' ) ) . toBe ( 'A' ) ;
@@ -165,6 +172,7 @@ describe('Parse module', () => {
165172 Parse . enableEncryptedUser ( ) ;
166173 expect ( Parse . encryptedUser ) . toBe ( true ) ;
167174 expect ( Parse . isEncryptedUserEnabled ( ) ) . toBe ( true ) ;
175+ process . env . PARSE_BUILD = 'node' ;
168176 } ) ;
169177
170178 it ( 'can set an encrypt token as String' , ( ) => {
@@ -240,10 +248,13 @@ describe('Parse module', () => {
240248 } ) ;
241249
242250 it ( 'can get IndexedDB storage' , ( ) => {
243- console . log ( Parse . IndexedDB ) ;
244- expect ( Parse . IndexedDB ) . toBeDefined ( ) ;
245- CoreManager . setStorageController ( Parse . IndexedDB ) ;
251+ expect ( Parse . IndexedDB ) . toBeUndefined ( ) ;
252+ process . env . PARSE_BUILD = 'browser' ;
253+ const ParseInstance = require ( '../Parse' ) ;
254+ expect ( ParseInstance . IndexedDB ) . toBeDefined ( ) ;
255+ CoreManager . setStorageController ( ParseInstance . IndexedDB ) ;
246256 const currentStorage = CoreManager . getStorageController ( ) ;
247- expect ( currentStorage ) . toEqual ( Parse . IndexedDB ) ;
257+ expect ( currentStorage ) . toEqual ( ParseInstance . IndexedDB ) ;
258+ process . env . PARSE_BUILD = 'node' ;
248259 } ) ;
249260} ) ;
0 commit comments