Skip to content

Commit

Permalink
test: ensure only public keys passed to 'sendRequestAccountResponseTo…
Browse files Browse the repository at this point in the history
…Tab'
  • Loading branch information
kyranjamie committed Apr 22, 2022
1 parent ee98fb4 commit c3e9693
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/app/common/actions/send-request-account-response.spec.ts
Original file line number Diff line number Diff line change
@@ -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' },
]);
});
});
2 changes: 1 addition & 1 deletion src/app/common/actions/send-request-account-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export function sendRequestAccountResponseToTab(args: SendRequestAccountResponse
dataPublicKey: account.dataPublicKey,
};

return sendMessageToTab(parseInt(tabId), id, safeAccountKeys);
return sendMessageToTab(parseInt(tabId), id, [safeAccountKeys]);
}
2 changes: 1 addition & 1 deletion src/app/pages/choose-account-request/account-request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c3e9693

Please sign in to comment.