Skip to content

Commit

Permalink
Add a 'cause' field to error objects in tests
Browse files Browse the repository at this point in the history
Some error objects should have a 'cause' field that will capture inner causes of particular errors.
  • Loading branch information
Mrtenz committed Apr 19, 2023
1 parent c2cef5d commit 2c37d50
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/permission-controller/src/PermissionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5288,7 +5288,11 @@ describe('PermissionController', () => {
};

const expectedError = errors.unauthorized({
data: { origin, method: PermissionNames.wallet_getSecretArray },
data: {
origin,
method: PermissionNames.wallet_getSecretArray,
cause: null,
},
});

const { error }: any = await engine.handle(request);
Expand All @@ -5308,7 +5312,10 @@ describe('PermissionController', () => {
method: 'wallet_foo',
};

const expectedError = errors.methodNotFound('wallet_foo', { origin });
const expectedError = errors.methodNotFound('wallet_foo', {
origin,
cause: null,
});

const { error }: any = await engine.handle(request);
expect(error).toMatchObject(expect.objectContaining(expectedError));
Expand Down Expand Up @@ -5348,7 +5355,7 @@ describe('PermissionController', () => {

const expectedError = errors.internalError(
`Request for method "${PermissionNames.wallet_doubleNumber}" returned undefined result.`,
{ request: { ...request } },
{ request: { ...request }, cause: null },
);

const { error }: any = await engine.handle(request);
Expand Down

0 comments on commit 2c37d50

Please sign in to comment.