Skip to content

Commit

Permalink
EngineService: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcloureiro committed Aug 2, 2023
1 parent b087c15 commit a68818a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/core/EngineService/EngineService.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import configureMockStore from 'redux-mock-store';

Check failure on line 1 in app/core/EngineService/EngineService.test.ts

View workflow job for this annotation

GitHub Actions / scripts (lint)

'configureMockStore' is defined but never used
import EngineService from './EngineService';
import Engine from '../Engine';
import { store } from '../../store'

Check failure on line 4 in app/core/EngineService/EngineService.test.ts

View workflow job for this annotation

GitHub Actions / scripts (lint)

Insert `;`

Check warning on line 4 in app/core/EngineService/EngineService.test.ts

View workflow job for this annotation

GitHub Actions / scripts (lint)

Missing semicolon

jest.unmock('../Engine');

describe('EngineService', () => {
EngineService.initalizeEngine(store);
it('should have Engine initialized', () => {
expect(Engine.context).toBeDefined();
});
it('should have recovered vault on redux store ', async () => {
const { success } = await EngineService.initializeVaultFromBackup();
expect(success).toBeTruthy();
const { KeyringController } = store.getState().engine.backgroundState;
expect(KeyringController.vault).toBeDefined();
});
});
5 changes: 4 additions & 1 deletion app/util/test/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ jest.mock('react-native-keychain', () => ({
setInternetCredentials: jest
.fn(('server', 'username', 'password'))
.mockResolvedValue({ service: 'metamask', storage: 'storage' }),
resetInternetCredentials: jest.fn(),
getInternetCredentials: jest
.fn()
.mockResolvedValue({ password: 'mock-credentials-password' }),
resetInternetCredentials: jest.fn().mockResolvedValue(),
ACCESSIBLE: {
WHEN_UNLOCKED: 'AccessibleWhenUnlocked',
AFTER_FIRST_UNLOCK: 'AccessibleAfterFirstUnlock',
Expand Down

0 comments on commit a68818a

Please sign in to comment.