@@ -6,6 +6,7 @@ const sinon = require('sinon');
66const Wallet = require ( 'ethereumjs-wallet' ) . default ;
77
88const KeyringController = require ( '..' ) ;
9+ const { KeyringMockWithInit } = require ( './lib/mock-keyring' ) ;
910const mockEncryptor = require ( './lib/mock-encryptor' ) ;
1011
1112const password = 'password123' ;
@@ -33,6 +34,7 @@ describe('KeyringController', function () {
3334 beforeEach ( async function ( ) {
3435 keyringController = new KeyringController ( {
3536 encryptor : mockEncryptor ,
37+ keyringTypes : [ KeyringMockWithInit ] ,
3638 } ) ;
3739
3840 await keyringController . createNewVaultAndKeychain ( password ) ;
@@ -240,6 +242,23 @@ describe('KeyringController', function () {
240242 const allAccounts = await keyringController . getAccounts ( ) ;
241243 expect ( allAccounts ) . toHaveLength ( 3 ) ;
242244 } ) ;
245+
246+ it ( 'should call init method if available' , async function ( ) {
247+ const Keyring = keyringController . getKeyringClassForType (
248+ 'Keyring Mock With Init' ,
249+ ) ;
250+
251+ const initSpy = sinon . spy ( Keyring . prototype , 'init' ) ;
252+
253+ const keyring = await keyringController . addNewKeyring (
254+ 'Keyring Mock With Init' ,
255+ ) ;
256+
257+ const keyringAccounts = await keyring . getAccounts ( ) ;
258+ expect ( keyringAccounts ) . toHaveLength ( 0 ) ;
259+
260+ expect ( initSpy . calledOnce ) . toBe ( true ) ;
261+ } ) ;
243262 } ) ;
244263
245264 describe ( 'restoreKeyring' , function ( ) {
0 commit comments