Skip to content

Commit

Permalink
Add test suite for nft checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
octave08 committed Jun 23, 2023
1 parent fbf5b0b commit 5b5bf64
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import browserEnv from '@ikscodes/browser-env';
import { createMagicSDK } from '../../../factories';
import { isPromiEvent } from '../../../../src/util';

beforeEach(() => {
browserEnv.restore();
});

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

magic.nft.request = jest.fn().mockReturnValue({
status: 'complete',
viewInWallet: true,
});

magic.nft.checkout({
contractId: '1cd4cfe8-b997-466e-8b0d-ff1177222ba4',
contractAddress: '0x375625833431b22623ce222e55b1cd15a459ba49',
tokenId: '1',
name: 'NFT Checkout Test',
imageUrl: 'https://nft-cdn.alchemy.com/matic-mumbai/382ceb42f28fb4df0d12897d5d433084',
quantity: 1,
});

const requestPayload = magic.nft.request.mock.calls[0][0];
console.log(requestPayload.params);
expect(requestPayload.method).toBe('magic_nft_checkout');
expect(requestPayload.params).toMatchObject([
{
contractId: '1cd4cfe8-b997-466e-8b0d-ff1177222ba4',
contractAddress: '0x375625833431b22623ce222e55b1cd15a459ba49',
tokenId: '1',
name: 'NFT Checkout Test',
imageUrl: 'https://nft-cdn.alchemy.com/matic-mumbai/382ceb42f28fb4df0d12897d5d433084',
quantity: 1,
},
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ test('purchase method should return a PromiEvent', () => {
const magic = createMagicSDK();
expect(isPromiEvent(magic.nft.purchase())).toBeTruthy();
});

test('checkout method should return a PromiEvent', () => {
const magic = createMagicSDK();
expect(isPromiEvent(magic.nft.checkout())).toBeTruthy();
});

0 comments on commit 5b5bf64

Please sign in to comment.