diff --git a/src/app/common/actions/send-request-account-response.spec.ts b/src/app/common/actions/send-request-account-response.spec.ts new file mode 100644 index 0000000000..c633761eb2 --- /dev/null +++ b/src/app/common/actions/send-request-account-response.spec.ts @@ -0,0 +1,24 @@ +import { sendRequestAccountResponseToTab } from './send-request-account-response'; +import { sendMessageToTab } from '@shared/messages'; + +jest.mock('@shared/messages', () => ({ + sendMessageToTab: jest.fn().mockImplementation(() => null), +})); + +describe(sendRequestAccountResponseToTab.name, () => { + it('must only return to app with public keys', () => { + sendRequestAccountResponseToTab({ + tabId: '2', + id: '1', + account: { + stxPublicKey: 'pubKey1', + dataPublicKey: 'dataKey1', + stxPrivateKey: 'lskdjfjsldf', + } as any, + }); + expect(sendMessageToTab).toHaveBeenCalledTimes(1); + expect(sendMessageToTab).toHaveBeenCalledWith(2, '1', [ + { dataPublicKey: 'dataKey1', stxPublicKey: 'pubKey1' }, + ]); + }); +}); diff --git a/src/app/common/actions/send-request-account-response.ts b/src/app/common/actions/send-request-account-response.ts index ab882c3d19..f10bd2e77d 100644 --- a/src/app/common/actions/send-request-account-response.ts +++ b/src/app/common/actions/send-request-account-response.ts @@ -14,5 +14,5 @@ export function sendRequestAccountResponseToTab(args: SendRequestAccountResponse dataPublicKey: account.dataPublicKey, }; - return sendMessageToTab(parseInt(tabId), id, safeAccountKeys); + return sendMessageToTab(parseInt(tabId), id, [safeAccountKeys]); } diff --git a/src/app/pages/choose-account-request/account-request.tsx b/src/app/pages/choose-account-request/account-request.tsx index f384b1608b..d2dfd537f5 100644 --- a/src/app/pages/choose-account-request/account-request.tsx +++ b/src/app/pages/choose-account-request/account-request.tsx @@ -21,7 +21,7 @@ export function AccountRequest() { if (!accounts) throw new Error('Cannot request account details with no account'); if (!tabId || !id) { - logger.error('Missing either tabId or uuid. Both necessary to respond to app'); + logger.error('Missing either tabId or uuid. Both values are necessary to respond to app'); return; }