-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d45b4bb
commit 1dd82bd
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import Logger from '../../../../util/Logger'; | ||
import { logEngineCreation } from '../logger'; | ||
|
||
jest.mock('../../../../util/Logger'); | ||
|
||
describe('logEngineCreation', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('logs empty state initialization', () => { | ||
logEngineCreation({}, null); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Engine initialized with empty state', | ||
{ | ||
keyringStateFromBackup: false, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs empty state initialization with keyring backup', () => { | ||
logEngineCreation( | ||
{}, | ||
{ vault: 'test-vault', keyrings: [], isUnlocked: false }, | ||
); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Engine initialized with empty state', | ||
{ | ||
keyringStateFromBackup: true, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs non-empty state initialization with accounts', () => { | ||
const initialState = { | ||
AccountsController: { | ||
internalAccounts: { | ||
accounts: {}, | ||
selectedAccount: '', | ||
}, | ||
}, | ||
}; | ||
|
||
logEngineCreation(initialState, null); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Engine initialized with non-empty state', | ||
{ | ||
hasAccountsState: true, | ||
hasKeyringState: false, | ||
keyringStateFromBackup: false, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs non-empty state initialization with keyring state', () => { | ||
const initialState = { | ||
KeyringController: { | ||
vault: 'test-vault', | ||
keyrings: [], | ||
isUnlocked: false, | ||
}, | ||
}; | ||
|
||
logEngineCreation(initialState, null); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Engine initialized with non-empty state', | ||
{ | ||
hasAccountsState: false, | ||
hasKeyringState: true, | ||
keyringStateFromBackup: false, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs non-empty state initialization with both accounts and keyring', () => { | ||
const initialState = { | ||
AccountsController: { | ||
internalAccounts: { | ||
accounts: {}, | ||
selectedAccount: '', | ||
}, | ||
}, | ||
KeyringController: { | ||
vault: 'test-vault', | ||
keyrings: [], | ||
isUnlocked: false, | ||
}, | ||
}; | ||
|
||
const keyringBackup = { | ||
vault: 'backup-vault', | ||
keyrings: [], | ||
isUnlocked: false, | ||
}; | ||
|
||
logEngineCreation(initialState, keyringBackup); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Engine initialized with non-empty state', | ||
{ | ||
hasAccountsState: true, | ||
hasKeyringState: true, | ||
keyringStateFromBackup: true, | ||
}, | ||
); | ||
}); | ||
}); |