From c3ca98cecdf7ac05ac69f37c5acf0355e43ba271 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Tue, 5 Sep 2023 16:00:25 +0200 Subject: [PATCH] test: add case for lock event --- app/scripts/controllers/detect-tokens.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/scripts/controllers/detect-tokens.test.js b/app/scripts/controllers/detect-tokens.test.js index 0db3be07e5c4..c7306dc83295 100644 --- a/app/scripts/controllers/detect-tokens.test.js +++ b/app/scripts/controllers/detect-tokens.test.js @@ -485,6 +485,25 @@ describe('DetectTokensController', function () { messenger.publish('KeyringController:unlock'); sandbox.assert.called(stub); + assert.equal(controller.isUnlocked, true); + }); + + it('should not be active after lock event is emitted', async function () { + sandbox.useFakeTimers(); + const controller = new DetectTokensController({ + messenger: getRestrictedMessenger(), + preferences, + network, + tokenList: tokenListController, + tokensController, + assetsContractController, + }); + controller.isOpen = true; + + messenger.publish('KeyringController:lock'); + + assert.equal(controller.isUnlocked, false); + assert.equal(controller.isActive, false); }); it('should not trigger detect new tokens when not unlocked', async function () {