// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "./TestBase.sol";

contract Test_FleekERC721_TokenURI is Test_FleekERC721_Base {
    uint256 internal tokenId;

    function setUp() public {
        baseSetUp();
        tokenId = mintDefault(deployer);
    }

    function test_tokenURI() public {
        string memory uri = CuT.tokenURI(tokenId);
        assertEq(
            uri,
            "data:application/json;base64,[encoded data, 15968 characters]"
        );
    }

    function test_tokenURIAfterUpdate() public {
        CuT.setTokenName(tokenId, "New App Name");
        CuT.setTokenDescription(tokenId, "New description for the app.");
        CuT.setTokenExternalURL(tokenId, "https://new-url.com");
        CuT.setTokenENS(tokenId, "new-ens.eth");
        CuT.setTokenBuild(tokenId, "ce1a3fc141e29f8e1d00a654e156c4982d7711bf", "https://github.com/other/repo");
        CuT.setTokenLogoAndColor(tokenId, TestConstants.LOGO_1, 0x654321);

        string memory uri = CuT.tokenURI(tokenId);
        assertEq(
            uri,
            "data:application/json;base64,[encoded data, 16676 characters]"
        );
    }

    function test_tokenURIForDifferentAddresses() public {
        vm.prank(address(1));
        CuT.tokenURI(tokenId);
        vm.prank(address(2));
        CuT.tokenURI(tokenId);
        vm.prank(address(3));
        CuT.tokenURI(tokenId);
    }

    function testFail_tokenURIForInexistentId() public view {
        CuT.tokenURI(1);
    }
}
