Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ddw 1091 fix unpredictably failing test #2973

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions source/renderer/app/components/wallet/WalletSendForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,26 @@ describe('wallet/Wallet Send Form', () => {
}

function createTransactionFeeMock(times: number, minimumAda: number) {
const mock = jest.fn().mockResolvedValue({
fee: new BigNumber(1),
minimumAda: new BigNumber(1),
const mock = jest.fn().mockImplementation(() => {
// eslint-disable-next-line no-console
console.log('Default call');

return Promise.resolve({
fee: new BigNumber(1),
minimumAda: new BigNumber(1),
});
});
Array.from({
length: times,
}).forEach(() => {
// @ts-ignore
mock.mockResolvedValueOnce({
fee: new BigNumber(1),
minimumAda: new BigNumber(minimumAda),
}).forEach((_, index) => {
mock.mockImplementationOnce(() => {
// eslint-disable-next-line no-console
console.log(`Call ${index + 1}`);

return Promise.resolve({
fee: new BigNumber(1),
minimumAda: new BigNumber(minimumAda),
});
});
});
return mock;
Expand Down Expand Up @@ -374,7 +383,8 @@ describe('wallet/Wallet Send Form', () => {
expect(adaInput).toHaveValue(`${minimumAda},000000`);
});

test('should calculate transaction fee even when one of the assets are empty', async () => {
// eslint-disable-next-line
test.only('should calculate transaction fee even when one of the assets are empty', async () => {
expect.assertions(2);
const minimumAda = 2;
const calculateTransactionFeeMock = createTransactionFeeMock(4, minimumAda);
Expand All @@ -383,10 +393,25 @@ describe('wallet/Wallet Send Form', () => {
);
enterReceiverAddress();
await addToken(0);
// eslint-disable-next-line no-console
console.log(
'calculateTransactionFeeMock call count:',
calculateTransactionFeeMock.mock.calls.length
);
await waitForMinimumAdaRequiredMsg(1);
expect(getInput('Ada')).toHaveValue('');
await addToken(minimumAda, 1);
// eslint-disable-next-line no-console
console.log(
'calculateTransactionFeeMock call count:',
calculateTransactionFeeMock.mock.calls.length
);
await waitForMinimumAdaRequiredMsg();
// eslint-disable-next-line no-console
console.log(
'calculateTransactionFeeMock call count:',
calculateTransactionFeeMock.mock.calls.length
);
assertAdaInput(minimumAda);
});

Expand Down