2023-03-23 19:21:33 +01:00
|
|
|
import { renderHookWithProvider } from '../../test/lib/render-helpers';
|
2023-03-30 18:37:29 +02:00
|
|
|
import { hexToDecimal } from '../../shared/modules/conversion.utils';
|
2023-03-23 19:21:33 +01:00
|
|
|
import mockState from '../../test/data/mock-state.json';
|
|
|
|
import { useTransactionInfo } from './useTransactionInfo';
|
|
|
|
|
|
|
|
describe('useTransactionInfo', () => {
|
|
|
|
describe('isNftTransfer', () => {
|
|
|
|
it('should return false if transaction is not NFT transfer', () => {
|
|
|
|
const { result } = renderHookWithProvider(
|
|
|
|
() =>
|
|
|
|
useTransactionInfo({
|
|
|
|
txParams: {},
|
|
|
|
}),
|
|
|
|
mockState,
|
|
|
|
);
|
|
|
|
expect(result.current.isNftTransfer).toStrictEqual(false);
|
|
|
|
});
|
|
|
|
it('should return true if transaction is NFT transfer', () => {
|
|
|
|
mockState.metamask.allNftContracts = {
|
|
|
|
[mockState.metamask.selectedAddress]: {
|
2023-05-02 17:53:20 +02:00
|
|
|
[hexToDecimal(mockState.metamask.providerConfig.chainId)]: [
|
2023-03-30 18:37:29 +02:00
|
|
|
{ address: '0x9' },
|
|
|
|
],
|
2023-03-23 19:21:33 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const { result } = renderHookWithProvider(
|
|
|
|
() =>
|
|
|
|
useTransactionInfo({
|
|
|
|
txParams: {
|
|
|
|
to: '0x9',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
mockState,
|
|
|
|
);
|
|
|
|
expect(result.current.isNftTransfer).toStrictEqual(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|