UNPKG

@elizaos/plugin-squid-router

Version:

ElizaOS plugin for cross-chain token swaps using Squid Router

93 lines (78 loc) 3.41 kB
import { describe, it, expect } from "bun:test"; import { xChainSwapTemplate } from "../templates/index"; describe("xChainSwapTemplate", () => { it("should be a string", () => { expect(typeof xChainSwapTemplate).toBe("string"); }); it("should contain recentMessages placeholder", () => { expect(xChainSwapTemplate).toContain("{{recentMessages}}"); }); it("should describe extraction of swap parameters", () => { expect(xChainSwapTemplate).toContain("Extract the following information"); expect(xChainSwapTemplate).toContain("Token symbol to swap from"); expect(xChainSwapTemplate).toContain("Token symbol to swap into"); expect(xChainSwapTemplate).toContain("Source chain"); expect(xChainSwapTemplate).toContain("Destination chain"); expect(xChainSwapTemplate).toContain("Amount to swap"); expect(xChainSwapTemplate).toContain("Destination address"); }); it("should specify default behaviors", () => { expect(xChainSwapTemplate).toContain( "If the destination address is not specified" ); expect(xChainSwapTemplate).toContain( "If the token to swap into is not specified" ); expect(xChainSwapTemplate).toContain( "If the destination chain is not specified" ); }); it("should request XML response format", () => { expect(xChainSwapTemplate).toContain("Respond with an XML block"); expect(xChainSwapTemplate).toContain("<response>"); expect(xChainSwapTemplate).toContain("</response>"); }); it("should include all required XML fields", () => { expect(xChainSwapTemplate).toContain("<fromToken>"); expect(xChainSwapTemplate).toContain("<toToken>"); expect(xChainSwapTemplate).toContain("<fromChain>"); expect(xChainSwapTemplate).toContain("<toChain>"); expect(xChainSwapTemplate).toContain("<amount>"); expect(xChainSwapTemplate).toContain("<toAddress>"); }); it("should have proper XML closing tags", () => { expect(xChainSwapTemplate).toContain("</fromToken>"); expect(xChainSwapTemplate).toContain("</toToken>"); expect(xChainSwapTemplate).toContain("</fromChain>"); expect(xChainSwapTemplate).toContain("</toChain>"); expect(xChainSwapTemplate).toContain("</amount>"); expect(xChainSwapTemplate).toContain("</toAddress>"); }); it("should indicate null as possible value", () => { expect(xChainSwapTemplate).toContain("string or null"); }); it("should follow v1.x XML template format", () => { // Check that it doesn't contain old JSON format expect(xChainSwapTemplate).not.toContain("```json"); expect(xChainSwapTemplate).not.toContain("JSON markdown block"); // Check XML format const xmlMatch = xChainSwapTemplate.match(/<response>[\s\S]*<\/response>/); expect(xmlMatch).toBeTruthy(); }); it("should have proper template structure", () => { // Check beginning expect(xChainSwapTemplate.startsWith("Given the recent messages")).toBe( true ); // Check it has instructions section expect(xChainSwapTemplate).toContain("Extract the following information"); // Check it has defaults section expect(xChainSwapTemplate).toContain( "If the destination address is not specified" ); // Check it ends with response format expect(xChainSwapTemplate).toContain( "Respond with an XML block containing only the extracted values" ); }); });