Skip to content

Commit

Permalink
chore: test update
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Jul 25, 2024
1 parent 51583c4 commit 8d7e23b
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -1672,33 +1669,15 @@ 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();

await testStreams[0].onFinishedCallbackPromise;

expect(
Array.from(metamaskController.finishedControllerStreamIds),
).toStrictEqual([]);
metamaskController.rawListeners('update')
).toHaveLength(0);
});
});

Expand Down

0 comments on commit 8d7e23b

Please sign in to comment.