Skip to content

Commit

Permalink
fix tests/lints
Browse files Browse the repository at this point in the history
  • Loading branch information
olaszakos committed Nov 6, 2024
1 parent 6b98b1b commit 84cd896
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions apps/wallet/src/components/accounts/TransferDialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import {
import { flushPromises } from '@vue/test-utils';
import { services } from '~/plugins/services.plugin';
import { ExtractOk } from '~/types/helper.types';
import { AddressFormat } from '~/types/chain.types';

const validIcpAddress = '5c76bc95e544204de4928e4d901e52b49df248b9c346807040e7af75aa61f4b3';

vi.mock('~/utils/asset.utils', () => ({
detectAddressStandard: vi.fn(() => 'icp_native'),
detectAddressFormat: vi.fn(() => AddressFormat.ICPNative),
}));

vi.mock('~/services/station.service', () => ({
Expand Down Expand Up @@ -112,21 +116,20 @@ describe('TransferDialog', () => {

const submitButton = form.find(`[data-test-id="transfer-dialog-save-button"]`);

amount.find('input').setValue('1');
destination.find('input').setValue('destination address');
summary.find('input').setValue('test summary');
await amount.find('input').setValue('1');
await destination.find('input').setValue(validIcpAddress);
await summary.find('input').setValue('test summary');

await flushPromises();

await submitButton.trigger('click');

await wrapper.vm.$nextTick();
await flushPromises();

expect(services().station.transfer).toHaveBeenCalledWith(
expect.objectContaining({
amount: 100n, // decimals are 2
to: 'destination address',
to: validIcpAddress,
}),
'test summary',
);
Expand All @@ -143,7 +146,7 @@ describe('TransferDialog', () => {
services().station.getTransfer = vi.fn(() =>
Promise.resolve({
id: 'transfer-id',
to: 'destination address',
to: validIcpAddress,
amount: 123n,
request_id: 'request-id',
} as Transfer),
Expand Down Expand Up @@ -181,7 +184,7 @@ describe('TransferDialog', () => {
expect(transferId.find('input').element.value).toBe('transfer-id');

expect(amount.find('input').element.value).toBe('1.23');
expect(destination.find('input').element.value).toBe('destination address');
expect(destination.find('input').element.value).toBe(validIcpAddress);
expect(summary.find('input').element.value).toBe('test summary');
});
});
1 change: 1 addition & 0 deletions apps/wallet/src/components/requests/RecentRequests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const props = withDefaults(
}>(),
{
title: undefined,
types: undefined,
limit: 3,
sortBy: () => ({
expirationDt: 'asc',
Expand Down
7 changes: 4 additions & 3 deletions apps/wallet/src/utils/form.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export const validAddress =
if (detectAddressFormat(blockchain, value) !== undefined) {
return true;
}
} catch {}

return i18n.global.t('forms.rules.validAddress');
return i18n.global.t('forms.rules.validAddress');
} catch {
return i18n.global.t('forms.rules.validAddress');
}
};

0 comments on commit 84cd896

Please sign in to comment.