-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathElfaAiPlugin.test.ts
More file actions
132 lines (123 loc) · 5.16 KB
/
ElfaAiPlugin.test.ts
File metadata and controls
132 lines (123 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import ElfaAiPlugin from "../src/elfaAiPlugin";
import { ExecutableGameFunctionStatus } from "@virtuals-protocol/game";
describe("ElfaAiPlugin real API tests", () => {
// Use a valid API key (not recommended for production)
const realApiKey = "your_api_key";
let elfaAiPlugin: ElfaAiPlugin;
beforeAll(() => {
elfaAiPlugin = new ElfaAiPlugin({
credentials: { apiKey: realApiKey },
});
});
describe("pingFunction", () => {
it("should return Done status with valid ping response", async () => {
const logger = jest.fn();
// Provide an empty object as the argument
const result = await elfaAiPlugin.pingFunction.executable(
{},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success", true);
expect(result.feedback).toHaveProperty("data");
});
});
describe("keyStatusFunction", () => {
it("should return Done status with valid key status response", async () => {
const logger = jest.fn();
// Provide an empty object as the argument
const result = await elfaAiPlugin.keyStatusFunction.executable(
{},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
describe("mentionsFunction", () => {
it("should return Done status with valid mentions response", async () => {
const logger = jest.fn();
// Using default values: limit=100, offset=0
const result = await elfaAiPlugin.mentionsFunction.executable(
{ limit: "100", offset: "0" },
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
describe("topMentionsFunction", () => {
it("should return Done status when provided a valid ticker and parameters", async () => {
const logger = jest.fn();
// Provide a valid ticker symbol; adjust the value based on your API's expected data.
const result = await elfaAiPlugin.topMentionsFunction.executable(
{
ticker: "$SOL",
timeWindow: "1h",
page: "1",
pageSize: "10",
},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
describe("searchMentionsFunction", () => {
it("should return Done status when provided valid keywords and date range", async () => {
const logger = jest.fn();
// Provide valid keywords and date range
const now = Math.floor(Date.now() / 1000);
const from = now - 86400 * 2; // 2 day ago
const result = await elfaAiPlugin.searchMentionsFunction.executable(
{
keywords: "ai, agent",
from: String(from),
to: String(now),
limit: "20",
},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
describe("trendingTokensFunction", () => {
it("should return Done status with trending tokens response", async () => {
const logger = jest.fn();
// Using default values: timeWindow=24h, page=1, pageSize=50, minMentions=5
const result = await elfaAiPlugin.trendingTokensFunction.executable(
{
timeWindow: "24h",
page: "1",
pageSize: "50",
minMentions: "5",
},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
describe("accountSmartStatsFunction", () => {
it("should return Done status when provided a valid username", async () => {
const logger = jest.fn();
// Provide a valid username
const result =
await elfaAiPlugin.accountSmartStatsFunction.executable(
{
username: "elonmusk",
},
logger
);
expect(result.status).toBe(ExecutableGameFunctionStatus.Done);
expect(result.feedback).toHaveProperty("success");
expect(result.feedback).toHaveProperty("data");
});
});
});