Skip to content

Commit 40aeb52

Browse files
test: add environment check for ERC1155 mintToBatch tests (#5115)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR modifies the test for the `mintToBatch` function in the `ERC1155 Edition` to include conditional execution based on the presence of a `TW_SECRET_KEY`. It also refactors the test structure, improving readability and organization. ### Detailed summary - Changed `describe` to conditionally run based on `process.env.TW_SECRET_KEY`. - Refactored the test structure for `mintToBatch`. - Moved the `sendAndConfirmTransaction` call inside the test. - Added detailed NFT validation after minting. - Removed redundant code and improved clarity. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent e7bbc32 commit 40aeb52

File tree

1 file changed

+57
-54
lines changed

1 file changed

+57
-54
lines changed

packages/thirdweb/src/extensions/erc1155/write/mintToBatch.test.ts

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,65 @@ const chain = ANVIL_CHAIN;
1313
const client = TEST_CLIENT;
1414
const account = TEST_ACCOUNT_C;
1515

16-
describe("ERC1155 Edition: mintToBatch", () => {
17-
it("should mint multiple tokens in one tx", async () => {
18-
const contract = getContract({
19-
chain,
20-
client,
21-
address: await deployERC1155Contract({
16+
describe.runIf(process.env.TW_SECRET_KEY)(
17+
"ERC1155 Edition: mintToBatch",
18+
() => {
19+
it("should mint multiple tokens in one tx", async () => {
20+
const contract = getContract({
2221
chain,
2322
client,
23+
address: await deployERC1155Contract({
24+
chain,
25+
client,
26+
account,
27+
type: "TokenERC1155",
28+
params: {
29+
name: "edition",
30+
contractURI: TEST_CONTRACT_URI,
31+
},
32+
}),
33+
});
34+
35+
await sendAndConfirmTransaction({
2436
account,
25-
type: "TokenERC1155",
26-
params: {
27-
name: "edition",
28-
contractURI: TEST_CONTRACT_URI,
29-
},
30-
}),
31-
});
37+
transaction: mintToBatch({
38+
contract,
39+
to: account.address,
40+
nfts: [
41+
{ metadata: { name: "token 0" }, supply: 1n },
42+
{ metadata: { name: "token 1" }, supply: 2n },
43+
{ metadata: { name: "token 2" }, supply: 3n },
44+
],
45+
}),
46+
});
3247

33-
await sendAndConfirmTransaction({
34-
account,
35-
transaction: mintToBatch({
36-
contract,
37-
to: account.address,
38-
nfts: [
39-
{ metadata: { name: "token 0" }, supply: 1n },
40-
{ metadata: { name: "token 1" }, supply: 2n },
41-
{ metadata: { name: "token 2" }, supply: 3n },
42-
],
43-
}),
48+
const nfts = await getNFTs({ contract });
49+
expect(nfts).toStrictEqual([
50+
{
51+
metadata: { name: "token 0" },
52+
owner: null,
53+
id: 0n,
54+
tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0",
55+
type: "ERC1155",
56+
supply: 1n,
57+
},
58+
{
59+
metadata: { name: "token 1" },
60+
owner: null,
61+
id: 1n,
62+
tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0",
63+
type: "ERC1155",
64+
supply: 2n,
65+
},
66+
{
67+
metadata: { name: "token 2" },
68+
owner: null,
69+
id: 2n,
70+
tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0",
71+
type: "ERC1155",
72+
supply: 3n,
73+
},
74+
]);
4475
});
45-
46-
const nfts = await getNFTs({ contract });
47-
expect(nfts).toStrictEqual([
48-
{
49-
metadata: { name: "token 0" },
50-
owner: null,
51-
id: 0n,
52-
tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0",
53-
type: "ERC1155",
54-
supply: 1n,
55-
},
56-
{
57-
metadata: { name: "token 1" },
58-
owner: null,
59-
id: 1n,
60-
tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0",
61-
type: "ERC1155",
62-
supply: 2n,
63-
},
64-
{
65-
metadata: { name: "token 2" },
66-
owner: null,
67-
id: 2n,
68-
tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0",
69-
type: "ERC1155",
70-
supply: 3n,
71-
},
72-
]);
73-
});
74-
});
76+
},
77+
);

0 commit comments

Comments
 (0)