From 0cee80848d9aad2e59d2a3ed50141cf25707cb44 Mon Sep 17 00:00:00 2001 From: nu-xin Date: Sun, 1 Mar 2026 12:28:09 +0800 Subject: [PATCH 1/2] chore: add test script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 81fe8eed5a0cdea41e919ad87ef8f019ef90996f Mon Sep 17 00:00:00 2001 From: nu-xin Date: Sun, 1 Mar 2026 12:28:52 +0800 Subject: [PATCH 2/2] test: add basic URL parsing tests --- test/clone.test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/clone.test.js 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); + }); + }); +});