Skip to content

Commit

Permalink
Fix tc for sendGaslessTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
octave08 committed Sep 28, 2023
1 parent 23bb145 commit 1407c97
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import browserEnv from '@ikscodes/browser-env';
import { GaslessTransactionRequest } from '@magic-sdk/types';
import { createMagicSDK } from '../../../factories';
import { isPromiEvent } from '../../../../src/util';

Expand All @@ -11,20 +12,28 @@ test('Generate JSON RPC request payload with method `eth_sendGaslessTransaction`
magic.wallet.request = jest.fn();

const address = '0x1234';
const sericalizedTranasction = '0x1234567890abcdef';
const transaction: GaslessTransactionRequest = {
from: '0x1234',
to: '0x5678',
value: BigInt('12'),
};

magic.wallet.sendGaslessTransaction(address, sericalizedTranasction);
magic.wallet.sendGaslessTransaction(address, transaction);

const requestPayload = magic.wallet.request.mock.calls[0][0];
expect(requestPayload.method).toBe('eth_sendGaslessTransaction');
expect(requestPayload.params).toEqual([address, sericalizedTranasction]);
expect(requestPayload.params).toEqual([address, transaction]);
});

test('method should return a PromiEvent', () => {
const magic = createMagicSDK();

const address = '0x1234';
const sericalizedTranasction = '0x1234567890abcdef';
const transaction: GaslessTransactionRequest = {
from: '0x1234',
to: '0x5678',
value: BigInt('12'),
};

expect(isPromiEvent(magic.wallet.sendGaslessTransaction(address, sericalizedTranasction))).toBeTruthy();
expect(isPromiEvent(magic.wallet.sendGaslessTransaction(address, transaction))).toBeTruthy();
});

0 comments on commit 1407c97

Please sign in to comment.