Skip to content

Commit a445b85

Browse files
committed
fix coverage
1 parent 3d7ca81 commit a445b85

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/__tests__/ParseUser-test.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ describe('ParseUser', () => {
17491749
});
17501750
});
17511751

1752-
fit('can encrypt user', async () => {
1752+
it('can encrypt user', async () => {
17531753
CoreManager.set('ENCRYPTED_KEY', 'hello');
17541754

17551755
ParseUser.enableUnsafeCurrentUser();
@@ -1804,7 +1804,7 @@ describe('ParseUser', () => {
18041804
it('can encrypt user with custom CryptoController', async () => {
18051805
CoreManager.set('ENCRYPTED_KEY', 'hello');
18061806
const ENCRYPTED_DATA = 'encryptedString';
1807-
1807+
const CryptoController = CoreManager.getCryptoController();
18081808
ParseUser.enableUnsafeCurrentUser();
18091809
ParseUser._clearCache();
18101810
Storage._clear();
@@ -1828,6 +1828,7 @@ describe('ParseUser', () => {
18281828
ajax() {},
18291829
});
18301830
const CustomCrypto = {
1831+
async: 0,
18311832
encrypt(_obj, secretKey) {
18321833
expect(secretKey).toBe('hello');
18331834
return ENCRYPTED_DATA;
@@ -1843,20 +1844,32 @@ describe('ParseUser', () => {
18431844
// Clear cache to read from disk
18441845
ParseUser._clearCache();
18451846

1846-
const isCurrent = await u.isCurrentAsync();
18471847
expect(u.id).toBe('uid2');
18481848
expect(u.getSessionToken()).toBe('123abc');
1849-
expect(isCurrent).toBe(true);
1849+
expect(u.isCurrent()).toBe(true);
18501850
expect(u.authenticated()).toBe(true);
18511851
expect(ParseUser.current().id).toBe('uid2');
18521852

18531853
const path = Storage.generatePath('currentUser');
18541854
const userStorage = Storage.getItem(path);
18551855
expect(userStorage).toBe(ENCRYPTED_DATA);
18561856
CoreManager.set('ENCRYPTED_KEY', null);
1857+
CoreManager.setCryptoController(CryptoController);
18571858
Storage._clear();
18581859
});
18591860

1861+
it('cannot get synchronous current user with encryption enabled', async () => {
1862+
CoreManager.set('ENCRYPTED_KEY', 'hello');
1863+
ParseUser.enableUnsafeCurrentUser();
1864+
ParseUser._clearCache();
1865+
expect(() => {
1866+
ParseUser.current();
1867+
}).toThrow(
1868+
'Cannot call currentUser() when using a platform with an async encrypted storage system. Call currentUserAsync() instead.'
1869+
);
1870+
CoreManager.set('ENCRYPTED_KEY', null);
1871+
});
1872+
18601873
it('can static signup a user with installationId', async () => {
18611874
ParseUser.disableUnsafeCurrentUser();
18621875
ParseUser._clearCache();

0 commit comments

Comments
 (0)