Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kstepanovdev committed Feb 16, 2024
1 parent 694d46f commit 6db5958
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion clients/js/test/mintV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import {
generateSigner,
none,
publicKey,
some,
} from '@metaplex-foundation/umi';
import test from 'ava';
import { MetadataArgsArgs, fetchMerkleTree, hashLeaf, mintV1 } from '../src';
import {
MetadataArgsArgs,
TokenStandard,
fetchMerkleTree,
hashLeaf,
mintV1,
} from '../src';
import { createTree, createUmi } from './_setup';

test('it can mint an NFT from a Bubblegum tree', async (t) => {
Expand Down Expand Up @@ -46,3 +53,51 @@ test('it can mint an NFT from a Bubblegum tree', async (t) => {
});
t.is(merkleTreeAccount.tree.rightMostPath.leaf, publicKey(leaf));
});

test('it cannot mint an NFT from a Bubblegum tree because token standard is empty', async (t) => {
// Given an empty Bubblegum tree.
const umi = await createUmi();
const merkleTree = await createTree(umi);
const leafOwner = generateSigner(umi).publicKey;

// When we mint a new NFT from the tree using the following metadata.
const metadata: MetadataArgsArgs = {
name: 'My NFT',
uri: 'https://example.com/my-nft.json',
sellerFeeBasisPoints: 500, // 5%
collection: none(),
creators: [],
tokenStandard: none(),
};
const promise = mintV1(umi, {
leafOwner,
merkleTree,
metadata,
}).sendAndConfirm(umi);
// Then we expect a program error because metadata's token standard is empty.
await t.throwsAsync(promise, { name: 'InvalidTokenStandard' });
});

test('it cannot mint an NFT from a Bubblegum tree because token standard is wrong', async (t) => {
// Given an empty Bubblegum tree.
const umi = await createUmi();
const merkleTree = await createTree(umi);
const leafOwner = generateSigner(umi).publicKey;

// When we mint a new NFT from the tree using the following metadata.
const metadata: MetadataArgsArgs = {
name: 'My NFT',
uri: 'https://example.com/my-nft.json',
sellerFeeBasisPoints: 500, // 5%
collection: none(),
creators: [],
tokenStandard: some(TokenStandard.FungibleAsset),
};
const promise = mintV1(umi, {
leafOwner,
merkleTree,
metadata,
}).sendAndConfirm(umi);
// Then we expect a program error because metadata's token standard is FungibleAsset which is wrong.
await t.throwsAsync(promise, { name: 'InvalidTokenStandard' });
});

0 comments on commit 6db5958

Please sign in to comment.