diff --git a/package.json b/package.json index 36e923c..0d0bf21 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "build": "node scripts/extract-chains.js", "prepublishOnly": "npm run build", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "node test/clone.test.js" }, "keywords": [ "clone", diff --git a/test/clone.test.js b/test/clone.test.js new file mode 100644 index 0000000..00554f9 --- /dev/null +++ b/test/clone.test.js @@ -0,0 +1,29 @@ +import { describe, it, expect } from "vitest"; + +describe("clone-contract", () => { + describe("URL parsing", () => { + it("should parse Etherscan URL", () => { + const url = "https://etherscan.io/address/0x1234567890123456789012345678901234567890"; + // Simple validation test + expect(url).toContain("etherscan.io"); + expect(url).toContain("0x1234567890123456789012345678901234567890"); + }); + + it("should parse Blockscan URL", () => { + const url = "https://vscode.blockscan.com/ethereum/0x1234567890123456789012345678901234567890"; + expect(url).toContain("blockscan.com"); + expect(url).toContain("ethereum"); + }); + + it("should validate contract address format", () => { + const validAddress = "0x1234567890123456789012345678901234567890"; + const invalidAddress = "1234567890"; + + const isValid = /^0x[a-fA-F0-9]{40}$/.test(validAddress); + const isInvalid = /^0x[a-fA-F0-9]{40}$/.test(invalidAddress); + + expect(isValid).toBe(true); + expect(isInvalid).toBe(false); + }); + }); +});