|
|
@ -160,8 +160,10 @@ describe('permission background API methods', () => { |
|
|
|
describe('requestAccountsPermissionWithId', () => { |
|
|
|
describe('requestAccountsPermissionWithId', () => { |
|
|
|
it('request an accounts permission and returns the request id', async () => { |
|
|
|
it('request an accounts permission and returns the request id', async () => { |
|
|
|
const permissionController = { |
|
|
|
const permissionController = { |
|
|
|
requestPermissions: jest.fn().mockImplementationOnce(async () => { |
|
|
|
requestPermissions: jest |
|
|
|
return [null, { id: 'arbitraryId' }]; |
|
|
|
.fn() |
|
|
|
|
|
|
|
.mockImplementationOnce(async (_, __, { id }) => { |
|
|
|
|
|
|
|
return [null, { id }]; |
|
|
|
}), |
|
|
|
}), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -173,9 +175,13 @@ describe('permission background API methods', () => { |
|
|
|
expect(permissionController.requestPermissions).toHaveBeenCalledWith( |
|
|
|
expect(permissionController.requestPermissions).toHaveBeenCalledWith( |
|
|
|
{ origin: 'foo.com' }, |
|
|
|
{ origin: 'foo.com' }, |
|
|
|
{ eth_accounts: {} }, |
|
|
|
{ eth_accounts: {} }, |
|
|
|
|
|
|
|
{ id: expect.any(String) }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
expect(id).toStrictEqual('arbitraryId'); |
|
|
|
expect(id.length > 0).toBe(true); |
|
|
|
|
|
|
|
expect(id).toStrictEqual( |
|
|
|
|
|
|
|
permissionController.requestPermissions.mock.calls[0][2].id, |
|
|
|
|
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|