From 8d7e23b5e132133e15c3f3bbe875a9ecdc360089 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 25 Jul 2024 20:24:40 +0000 Subject: [PATCH] chore: test update --- app/scripts/metamask-controller.test.js | 29 ++++--------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/app/scripts/metamask-controller.test.js b/app/scripts/metamask-controller.test.js index d42beae3cae1..aee5adec7703 100644 --- a/app/scripts/metamask-controller.test.js +++ b/app/scripts/metamask-controller.test.js @@ -1594,7 +1594,7 @@ describe('MetaMaskController', () => { expect(metamaskController.activeControllerConnections).toBe(0); }); - it('adds controller connections, which when ended, add their stream ids to this.finishedControllerStreamIds', async () => { + it('safely handles unexpected closing of streams', async () => { jest .spyOn(metamaskController, 'triggerNetworkrequests') .mockImplementation(); @@ -1655,14 +1655,11 @@ describe('MetaMaskController', () => { {}, ); - expect( - Array.from(metamaskController.finishedControllerStreamIds), - ).toStrictEqual([]); - await testStreams[1].promise; testStreams[1].testStream.end(); await testStreams[3].promise; testStreams[3].testStream.end(); + testStreams[3].testStream.end(); await testStreams[4].promise; testStreams[4].testStream.end(); @@ -1672,24 +1669,6 @@ describe('MetaMaskController', () => { await testStreams[3].onFinishedCallbackPromise; await testStreams[4].onFinishedCallbackPromise; await testStreams[2].onFinishedCallbackPromise; - expect( - Array.from(metamaskController.finishedControllerStreamIds), - ).toStrictEqual( - expect.arrayContaining([ - expect.stringMatching( - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u, - ), - expect.stringMatching( - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u, - ), - expect.stringMatching( - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u, - ), - expect.stringMatching( - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u, - ), - ]), - ); await testStreams[0].promise; testStreams[0].testStream.end(); @@ -1697,8 +1676,8 @@ describe('MetaMaskController', () => { await testStreams[0].onFinishedCallbackPromise; expect( - Array.from(metamaskController.finishedControllerStreamIds), - ).toStrictEqual([]); + metamaskController.rawListeners('update') + ).toHaveLength(0); }); });