Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyYap committed May 22, 2023
1 parent 7ab3f12 commit 836aa5f
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions Week16/my-create-web3-dapp/contract/test/MyToken.t.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "forge-std/Test.sol";
import "../src/FDemo.sol";
import "../src/MyToken.sol";

contract FoundryDemoTest is Test {
FDemo instance;
contract MyTokenTest is Test {
MyTokens internal myToken;

function setUp() public {
instance = new FDemo();
function beforeEach() public override {
myToken = new MyToken();
}

function testMint() public {
string memory dummyTokenUri = "ipfs://metadata_url";
uint256 tokenId = instance.mint(dummyTokenUri);
function testTokenName() public {
string memory name = myToken.name();
assert.equal(name, "MyToken", "Incorrect token name");
}

function testTokenSymbol() public {
string memory symbol = myToken.symbol();
assert.equal(symbol, "MTK", "Incorrect token symbol");
}

assertEq(dummyTokenUri, instance.tokenURI(tokenId));
function testTokenDecimals() public {
uint8 decimals = myToken.decimals();
assert.equal(decimals, 18, "Incorrect token decimals");
}

// Add more test cases for other functions

function runTests() public {
testTokenName();
testTokenSymbol();
testTokenDecimals();
// TODO: Add more test functions to run
}
}

0 comments on commit 836aa5f

Please sign in to comment.