diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index 2acdbe5539..f200464c07 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -23,6 +23,12 @@ export default async (opts) => { // If no options is selected, opts.upgradeable will be undefined // We do not show test file for upgradeable contract // @ts-ignore - if (!opts || opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + if (!opts || opts.upgradeable === undefined || !opts.upgradeable) { + // @ts-ignore + if (erc1155.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default + // @ts-ignore + else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + } + return filesObj } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_mintable_test.sol b/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_mintable_test.sol new file mode 100644 index 0000000000..7e74447f4e --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_mintable_test.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "remix_tests.sol"; +import "remix_accounts.sol"; +import "../contracts/MyToken.sol"; + +contract MyTokenTest { + + MyToken s; + + function beforeAll () public { + address acc0 = TestsAccounts.getAccount(0); + // acc0 will be set as initial owner + s = new MyToken(acc0); + } + + function testSetURI () public { + string memory uri = "https://testuri.io/token"; + s.setURI(uri); + Assert.equal(s.uri(1), uri, "uri did not match"); + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 9dcb4f02f9..2a8b0c8f3c 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -29,7 +29,6 @@ export default async (opts) => { if (erc20.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default // @ts-ignore else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default - } return filesObj } diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index c7bb561e06..d898a60558 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -24,6 +24,11 @@ export default async (opts) => { // If no options is selected, opts.upgradeable will be undefined // We do not show test file for upgradeable contract // @ts-ignore - if (!opts || opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + if (!opts || opts.upgradeable === undefined || !opts.upgradeable) { + // @ts-ignore + if (erc721.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default + // @ts-ignore + else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + } return filesObj } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/tests/MyToken_mintable_test.sol b/libs/remix-ws-templates/src/templates/ozerc721/tests/MyToken_mintable_test.sol new file mode 100644 index 0000000000..94e5ba87d8 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/tests/MyToken_mintable_test.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "remix_tests.sol"; +import "remix_accounts.sol"; +import "../contracts/MyToken.sol"; + +contract MyTokenTest { + + MyToken s; + + function beforeAll () public { + address acc0 = TestsAccounts.getAccount(0); + // acc0 will be set as initial owner + s = new MyToken(acc0); + } + + function testTokenNameAndSymbol () public { + Assert.equal(s.name(), "MyToken", "token name did not match"); + Assert.equal(s.symbol(), "MTK", "token symbol did not match"); + } +} \ No newline at end of file