zumito-framework 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ import { EventEmitter } from 'tseep';
2
+ export declare function createTestFramework(overrides?: Record<string, any>): {
3
+ framework: any;
4
+ client: {
5
+ _listeners: Record<string, ((...args: any[]) => void)[]>;
6
+ on: import("vitest").Mock<[event: string, cb: (...args: any[]) => void], void>;
7
+ once: import("vitest").Mock<[event: string, cb: (...args: any[]) => void], void>;
8
+ emit: import("vitest").Mock<[event: string, ...args: any[]], void>;
9
+ login: import("vitest").Mock<any, any>;
10
+ destroy: import("vitest").Mock<any, any>;
11
+ guilds: {
12
+ cache: Map<any, any>;
13
+ fetch: import("vitest").Mock<any, any>;
14
+ };
15
+ channels: {
16
+ cache: Map<any, any>;
17
+ fetch: import("vitest").Mock<any, any>;
18
+ };
19
+ user: {
20
+ id: string;
21
+ tag: string;
22
+ username: string;
23
+ };
24
+ users: {
25
+ fetch: import("vitest").Mock<any, any>;
26
+ };
27
+ options: {};
28
+ };
29
+ eventEmitter: EventEmitter<import("tseep").DefaultEventMap>;
30
+ };
@@ -0,0 +1,56 @@
1
+ import { vi } from 'vitest';
2
+ import { EventEmitter } from 'tseep';
3
+ import { ServiceContainer } from '../services/ServiceContainer.js';
4
+ import { createMockClient } from './mocks/discord.js';
5
+ export function createTestFramework(overrides = {}) {
6
+ ServiceContainer.services.clear();
7
+ const mockClient = createMockClient(overrides.client);
8
+ const eventEmitter = new EventEmitter();
9
+ const mockFramework = {
10
+ client: mockClient,
11
+ commands: {
12
+ size: 0,
13
+ set: vi.fn(),
14
+ get: vi.fn(),
15
+ getAll: vi.fn().mockReturnValue(new Map()),
16
+ },
17
+ events: new Map(),
18
+ translations: {
19
+ get: vi.fn(),
20
+ getAll: vi.fn().mockReturnValue(new Map()),
21
+ registerTranslationsFromFolder: vi.fn(),
22
+ },
23
+ settings: {
24
+ defaultPrefix: '!',
25
+ ...overrides.settings,
26
+ },
27
+ eventEmitter,
28
+ eventManager: {
29
+ addEventEmitter: vi.fn(),
30
+ addEventListener: vi.fn(),
31
+ getEventEmitter: vi.fn(),
32
+ eventEmitters: new Map(),
33
+ },
34
+ routes: [],
35
+ registerRoute: vi.fn(),
36
+ modules: {
37
+ set: vi.fn(),
38
+ get: vi.fn(),
39
+ getAll: vi.fn().mockReturnValue(new Map()),
40
+ size: 0,
41
+ },
42
+ ...overrides.framework,
43
+ };
44
+ ServiceContainer.addService(class ZumitoFramework {
45
+ }, [], true, mockFramework);
46
+ class MockErrorHandler {
47
+ handleError = vi.fn();
48
+ }
49
+ ServiceContainer.addService(class ErrorHandler {
50
+ }, [], true, new MockErrorHandler());
51
+ return {
52
+ framework: mockFramework,
53
+ client: mockClient,
54
+ eventEmitter,
55
+ };
56
+ }
@@ -0,0 +1,2 @@
1
+ export { createTestFramework } from './createTestFramework.js';
2
+ export { createMockClient, createMockGuild, createMockTextChannel, createMockGuildMember, createMockMessage, createMockCommandInteraction, createMockButtonInteraction, createMockStringSelectMenuInteraction, createMockModalSubmitInteraction, } from './mocks/discord.js';
@@ -0,0 +1,2 @@
1
+ export { createTestFramework } from './createTestFramework.js';
2
+ export { createMockClient, createMockGuild, createMockTextChannel, createMockGuildMember, createMockMessage, createMockCommandInteraction, createMockButtonInteraction, createMockStringSelectMenuInteraction, createMockModalSubmitInteraction, } from './mocks/discord.js';
@@ -0,0 +1,557 @@
1
+ export declare function createMockClient(overrides?: Record<string, any>): {
2
+ _listeners: Record<string, ((...args: any[]) => void)[]>;
3
+ on: import("vitest").Mock<[event: string, cb: (...args: any[]) => void], void>;
4
+ once: import("vitest").Mock<[event: string, cb: (...args: any[]) => void], void>;
5
+ emit: import("vitest").Mock<[event: string, ...args: any[]], void>;
6
+ login: import("vitest").Mock<any, any>;
7
+ destroy: import("vitest").Mock<any, any>;
8
+ guilds: {
9
+ cache: Map<any, any>;
10
+ fetch: import("vitest").Mock<any, any>;
11
+ };
12
+ channels: {
13
+ cache: Map<any, any>;
14
+ fetch: import("vitest").Mock<any, any>;
15
+ };
16
+ user: {
17
+ id: string;
18
+ tag: string;
19
+ username: string;
20
+ };
21
+ users: {
22
+ fetch: import("vitest").Mock<any, any>;
23
+ };
24
+ options: {};
25
+ };
26
+ export declare function createMockGuild(overrides?: Record<string, any>): {
27
+ id: string;
28
+ name: string;
29
+ ownerId: string;
30
+ channels: {
31
+ cache: Map<any, any>;
32
+ fetch: import("vitest").Mock<any, any>;
33
+ };
34
+ members: {
35
+ cache: Map<any, any>;
36
+ fetch: import("vitest").Mock<any, any>;
37
+ };
38
+ roles: {
39
+ cache: Map<any, any>;
40
+ };
41
+ };
42
+ export declare function createMockTextChannel(overrides?: Record<string, any>): {
43
+ id: string;
44
+ type: number;
45
+ name: string;
46
+ guild: {
47
+ id: string;
48
+ name: string;
49
+ ownerId: string;
50
+ channels: {
51
+ cache: Map<any, any>;
52
+ fetch: import("vitest").Mock<any, any>;
53
+ };
54
+ members: {
55
+ cache: Map<any, any>;
56
+ fetch: import("vitest").Mock<any, any>;
57
+ };
58
+ roles: {
59
+ cache: Map<any, any>;
60
+ };
61
+ };
62
+ isTextBased: import("vitest").Mock<any, any>;
63
+ isDMBased: import("vitest").Mock<any, any>;
64
+ nsfw: boolean;
65
+ send: import("vitest").Mock<any, any>;
66
+ permissionsFor: import("vitest").Mock<any, any>;
67
+ };
68
+ export declare function createMockGuildMember(overrides?: Record<string, any>): {
69
+ id: string;
70
+ user: {
71
+ id: string;
72
+ username: string;
73
+ };
74
+ guild: {
75
+ id: string;
76
+ name: string;
77
+ ownerId: string;
78
+ channels: {
79
+ cache: Map<any, any>;
80
+ fetch: import("vitest").Mock<any, any>;
81
+ };
82
+ members: {
83
+ cache: Map<any, any>;
84
+ fetch: import("vitest").Mock<any, any>;
85
+ };
86
+ roles: {
87
+ cache: Map<any, any>;
88
+ };
89
+ };
90
+ permissions: {
91
+ has: import("vitest").Mock<any, any>;
92
+ };
93
+ roles: {
94
+ cache: Map<any, any>;
95
+ };
96
+ };
97
+ export declare function createMockMessage(overrides?: Record<string, any>): {
98
+ id: string;
99
+ content: string;
100
+ author: {
101
+ id: string;
102
+ user: {
103
+ id: string;
104
+ username: string;
105
+ };
106
+ guild: {
107
+ id: string;
108
+ name: string;
109
+ ownerId: string;
110
+ channels: {
111
+ cache: Map<any, any>;
112
+ fetch: import("vitest").Mock<any, any>;
113
+ };
114
+ members: {
115
+ cache: Map<any, any>;
116
+ fetch: import("vitest").Mock<any, any>;
117
+ };
118
+ roles: {
119
+ cache: Map<any, any>;
120
+ };
121
+ };
122
+ permissions: {
123
+ has: import("vitest").Mock<any, any>;
124
+ };
125
+ roles: {
126
+ cache: Map<any, any>;
127
+ };
128
+ };
129
+ channel: {
130
+ id: string;
131
+ type: number;
132
+ name: string;
133
+ guild: {
134
+ id: string;
135
+ name: string;
136
+ ownerId: string;
137
+ channels: {
138
+ cache: Map<any, any>;
139
+ fetch: import("vitest").Mock<any, any>;
140
+ };
141
+ members: {
142
+ cache: Map<any, any>;
143
+ fetch: import("vitest").Mock<any, any>;
144
+ };
145
+ roles: {
146
+ cache: Map<any, any>;
147
+ };
148
+ };
149
+ isTextBased: import("vitest").Mock<any, any>;
150
+ isDMBased: import("vitest").Mock<any, any>;
151
+ nsfw: boolean;
152
+ send: import("vitest").Mock<any, any>;
153
+ permissionsFor: import("vitest").Mock<any, any>;
154
+ };
155
+ guild: {
156
+ id: string;
157
+ name: string;
158
+ ownerId: string;
159
+ channels: {
160
+ cache: Map<any, any>;
161
+ fetch: import("vitest").Mock<any, any>;
162
+ };
163
+ members: {
164
+ cache: Map<any, any>;
165
+ fetch: import("vitest").Mock<any, any>;
166
+ };
167
+ roles: {
168
+ cache: Map<any, any>;
169
+ };
170
+ };
171
+ guildId: string;
172
+ member: {
173
+ id: string;
174
+ user: {
175
+ id: string;
176
+ username: string;
177
+ };
178
+ guild: {
179
+ id: string;
180
+ name: string;
181
+ ownerId: string;
182
+ channels: {
183
+ cache: Map<any, any>;
184
+ fetch: import("vitest").Mock<any, any>;
185
+ };
186
+ members: {
187
+ cache: Map<any, any>;
188
+ fetch: import("vitest").Mock<any, any>;
189
+ };
190
+ roles: {
191
+ cache: Map<any, any>;
192
+ };
193
+ };
194
+ permissions: {
195
+ has: import("vitest").Mock<any, any>;
196
+ };
197
+ roles: {
198
+ cache: Map<any, any>;
199
+ };
200
+ };
201
+ reply: import("vitest").Mock<any, any>;
202
+ delete: import("vitest").Mock<any, any>;
203
+ react: import("vitest").Mock<any, any>;
204
+ editable: boolean;
205
+ deletable: boolean;
206
+ };
207
+ export declare function createMockCommandInteraction(overrides?: Record<string, any>): {
208
+ id: string;
209
+ commandName: string;
210
+ guild: {
211
+ id: string;
212
+ name: string;
213
+ ownerId: string;
214
+ channels: {
215
+ cache: Map<any, any>;
216
+ fetch: import("vitest").Mock<any, any>;
217
+ };
218
+ members: {
219
+ cache: Map<any, any>;
220
+ fetch: import("vitest").Mock<any, any>;
221
+ };
222
+ roles: {
223
+ cache: Map<any, any>;
224
+ };
225
+ };
226
+ guildId: string;
227
+ channel: {
228
+ id: string;
229
+ type: number;
230
+ name: string;
231
+ guild: {
232
+ id: string;
233
+ name: string;
234
+ ownerId: string;
235
+ channels: {
236
+ cache: Map<any, any>;
237
+ fetch: import("vitest").Mock<any, any>;
238
+ };
239
+ members: {
240
+ cache: Map<any, any>;
241
+ fetch: import("vitest").Mock<any, any>;
242
+ };
243
+ roles: {
244
+ cache: Map<any, any>;
245
+ };
246
+ };
247
+ isTextBased: import("vitest").Mock<any, any>;
248
+ isDMBased: import("vitest").Mock<any, any>;
249
+ nsfw: boolean;
250
+ send: import("vitest").Mock<any, any>;
251
+ permissionsFor: import("vitest").Mock<any, any>;
252
+ };
253
+ member: {
254
+ id: string;
255
+ user: {
256
+ id: string;
257
+ username: string;
258
+ };
259
+ guild: {
260
+ id: string;
261
+ name: string;
262
+ ownerId: string;
263
+ channels: {
264
+ cache: Map<any, any>;
265
+ fetch: import("vitest").Mock<any, any>;
266
+ };
267
+ members: {
268
+ cache: Map<any, any>;
269
+ fetch: import("vitest").Mock<any, any>;
270
+ };
271
+ roles: {
272
+ cache: Map<any, any>;
273
+ };
274
+ };
275
+ permissions: {
276
+ has: import("vitest").Mock<any, any>;
277
+ };
278
+ roles: {
279
+ cache: Map<any, any>;
280
+ };
281
+ };
282
+ user: {
283
+ id: string;
284
+ username: string;
285
+ };
286
+ reply: import("vitest").Mock<any, any>;
287
+ deferReply: import("vitest").Mock<any, any>;
288
+ editReply: import("vitest").Mock<any, any>;
289
+ followUp: import("vitest").Mock<any, any>;
290
+ options: {
291
+ get: import("vitest").Mock<any, any>;
292
+ getString: import("vitest").Mock<any, any>;
293
+ getInteger: import("vitest").Mock<any, any>;
294
+ getBoolean: import("vitest").Mock<any, any>;
295
+ getUser: import("vitest").Mock<any, any>;
296
+ getChannel: import("vitest").Mock<any, any>;
297
+ getRole: import("vitest").Mock<any, any>;
298
+ getSubcommand: import("vitest").Mock<any, any>;
299
+ };
300
+ };
301
+ export declare function createMockButtonInteraction(overrides?: Record<string, any>): {
302
+ id: string;
303
+ customId: string;
304
+ guild: {
305
+ id: string;
306
+ name: string;
307
+ ownerId: string;
308
+ channels: {
309
+ cache: Map<any, any>;
310
+ fetch: import("vitest").Mock<any, any>;
311
+ };
312
+ members: {
313
+ cache: Map<any, any>;
314
+ fetch: import("vitest").Mock<any, any>;
315
+ };
316
+ roles: {
317
+ cache: Map<any, any>;
318
+ };
319
+ };
320
+ guildId: string;
321
+ channel: {
322
+ id: string;
323
+ type: number;
324
+ name: string;
325
+ guild: {
326
+ id: string;
327
+ name: string;
328
+ ownerId: string;
329
+ channels: {
330
+ cache: Map<any, any>;
331
+ fetch: import("vitest").Mock<any, any>;
332
+ };
333
+ members: {
334
+ cache: Map<any, any>;
335
+ fetch: import("vitest").Mock<any, any>;
336
+ };
337
+ roles: {
338
+ cache: Map<any, any>;
339
+ };
340
+ };
341
+ isTextBased: import("vitest").Mock<any, any>;
342
+ isDMBased: import("vitest").Mock<any, any>;
343
+ nsfw: boolean;
344
+ send: import("vitest").Mock<any, any>;
345
+ permissionsFor: import("vitest").Mock<any, any>;
346
+ };
347
+ member: {
348
+ id: string;
349
+ user: {
350
+ id: string;
351
+ username: string;
352
+ };
353
+ guild: {
354
+ id: string;
355
+ name: string;
356
+ ownerId: string;
357
+ channels: {
358
+ cache: Map<any, any>;
359
+ fetch: import("vitest").Mock<any, any>;
360
+ };
361
+ members: {
362
+ cache: Map<any, any>;
363
+ fetch: import("vitest").Mock<any, any>;
364
+ };
365
+ roles: {
366
+ cache: Map<any, any>;
367
+ };
368
+ };
369
+ permissions: {
370
+ has: import("vitest").Mock<any, any>;
371
+ };
372
+ roles: {
373
+ cache: Map<any, any>;
374
+ };
375
+ };
376
+ user: {
377
+ id: string;
378
+ username: string;
379
+ };
380
+ reply: import("vitest").Mock<any, any>;
381
+ deferReply: import("vitest").Mock<any, any>;
382
+ deferUpdate: import("vitest").Mock<any, any>;
383
+ update: import("vitest").Mock<any, any>;
384
+ };
385
+ export declare function createMockStringSelectMenuInteraction(overrides?: Record<string, any>): {
386
+ id: string;
387
+ customId: string;
388
+ values: string[];
389
+ guild: {
390
+ id: string;
391
+ name: string;
392
+ ownerId: string;
393
+ channels: {
394
+ cache: Map<any, any>;
395
+ fetch: import("vitest").Mock<any, any>;
396
+ };
397
+ members: {
398
+ cache: Map<any, any>;
399
+ fetch: import("vitest").Mock<any, any>;
400
+ };
401
+ roles: {
402
+ cache: Map<any, any>;
403
+ };
404
+ };
405
+ guildId: string;
406
+ channel: {
407
+ id: string;
408
+ type: number;
409
+ name: string;
410
+ guild: {
411
+ id: string;
412
+ name: string;
413
+ ownerId: string;
414
+ channels: {
415
+ cache: Map<any, any>;
416
+ fetch: import("vitest").Mock<any, any>;
417
+ };
418
+ members: {
419
+ cache: Map<any, any>;
420
+ fetch: import("vitest").Mock<any, any>;
421
+ };
422
+ roles: {
423
+ cache: Map<any, any>;
424
+ };
425
+ };
426
+ isTextBased: import("vitest").Mock<any, any>;
427
+ isDMBased: import("vitest").Mock<any, any>;
428
+ nsfw: boolean;
429
+ send: import("vitest").Mock<any, any>;
430
+ permissionsFor: import("vitest").Mock<any, any>;
431
+ };
432
+ member: {
433
+ id: string;
434
+ user: {
435
+ id: string;
436
+ username: string;
437
+ };
438
+ guild: {
439
+ id: string;
440
+ name: string;
441
+ ownerId: string;
442
+ channels: {
443
+ cache: Map<any, any>;
444
+ fetch: import("vitest").Mock<any, any>;
445
+ };
446
+ members: {
447
+ cache: Map<any, any>;
448
+ fetch: import("vitest").Mock<any, any>;
449
+ };
450
+ roles: {
451
+ cache: Map<any, any>;
452
+ };
453
+ };
454
+ permissions: {
455
+ has: import("vitest").Mock<any, any>;
456
+ };
457
+ roles: {
458
+ cache: Map<any, any>;
459
+ };
460
+ };
461
+ user: {
462
+ id: string;
463
+ username: string;
464
+ };
465
+ reply: import("vitest").Mock<any, any>;
466
+ deferReply: import("vitest").Mock<any, any>;
467
+ deferUpdate: import("vitest").Mock<any, any>;
468
+ update: import("vitest").Mock<any, any>;
469
+ };
470
+ export declare function createMockModalSubmitInteraction(overrides?: Record<string, any>): {
471
+ id: string;
472
+ customId: string;
473
+ fields: {
474
+ getTextInputValue: import("vitest").Mock<any, any>;
475
+ getField: import("vitest").Mock<any, any>;
476
+ fields: any[];
477
+ };
478
+ guild: {
479
+ id: string;
480
+ name: string;
481
+ ownerId: string;
482
+ channels: {
483
+ cache: Map<any, any>;
484
+ fetch: import("vitest").Mock<any, any>;
485
+ };
486
+ members: {
487
+ cache: Map<any, any>;
488
+ fetch: import("vitest").Mock<any, any>;
489
+ };
490
+ roles: {
491
+ cache: Map<any, any>;
492
+ };
493
+ };
494
+ guildId: string;
495
+ channel: {
496
+ id: string;
497
+ type: number;
498
+ name: string;
499
+ guild: {
500
+ id: string;
501
+ name: string;
502
+ ownerId: string;
503
+ channels: {
504
+ cache: Map<any, any>;
505
+ fetch: import("vitest").Mock<any, any>;
506
+ };
507
+ members: {
508
+ cache: Map<any, any>;
509
+ fetch: import("vitest").Mock<any, any>;
510
+ };
511
+ roles: {
512
+ cache: Map<any, any>;
513
+ };
514
+ };
515
+ isTextBased: import("vitest").Mock<any, any>;
516
+ isDMBased: import("vitest").Mock<any, any>;
517
+ nsfw: boolean;
518
+ send: import("vitest").Mock<any, any>;
519
+ permissionsFor: import("vitest").Mock<any, any>;
520
+ };
521
+ member: {
522
+ id: string;
523
+ user: {
524
+ id: string;
525
+ username: string;
526
+ };
527
+ guild: {
528
+ id: string;
529
+ name: string;
530
+ ownerId: string;
531
+ channels: {
532
+ cache: Map<any, any>;
533
+ fetch: import("vitest").Mock<any, any>;
534
+ };
535
+ members: {
536
+ cache: Map<any, any>;
537
+ fetch: import("vitest").Mock<any, any>;
538
+ };
539
+ roles: {
540
+ cache: Map<any, any>;
541
+ };
542
+ };
543
+ permissions: {
544
+ has: import("vitest").Mock<any, any>;
545
+ };
546
+ roles: {
547
+ cache: Map<any, any>;
548
+ };
549
+ };
550
+ user: {
551
+ id: string;
552
+ username: string;
553
+ };
554
+ reply: import("vitest").Mock<any, any>;
555
+ deferReply: import("vitest").Mock<any, any>;
556
+ deferUpdate: import("vitest").Mock<any, any>;
557
+ };
@@ -0,0 +1,183 @@
1
+ import { vi } from 'vitest';
2
+ export function createMockClient(overrides = {}) {
3
+ const listeners = {};
4
+ return {
5
+ on: vi.fn((event, cb) => {
6
+ if (!listeners[event])
7
+ listeners[event] = [];
8
+ listeners[event].push(cb);
9
+ }),
10
+ once: vi.fn((event, cb) => {
11
+ if (!listeners[event])
12
+ listeners[event] = [];
13
+ listeners[event].push(cb);
14
+ }),
15
+ emit: vi.fn((event, ...args) => {
16
+ if (listeners[event]) {
17
+ listeners[event].forEach((cb) => cb(...args));
18
+ }
19
+ }),
20
+ login: vi.fn().mockResolvedValue('token'),
21
+ destroy: vi.fn(),
22
+ guilds: {
23
+ cache: new Map(),
24
+ fetch: vi.fn(),
25
+ },
26
+ channels: {
27
+ cache: new Map(),
28
+ fetch: vi.fn(),
29
+ },
30
+ user: { id: '123456789', tag: 'TestBot#0000', username: 'TestBot' },
31
+ users: {
32
+ fetch: vi.fn(),
33
+ },
34
+ options: {},
35
+ ...overrides,
36
+ _listeners: listeners,
37
+ };
38
+ }
39
+ export function createMockGuild(overrides = {}) {
40
+ return {
41
+ id: 'guild-123',
42
+ name: 'Test Guild',
43
+ ownerId: 'owner-123',
44
+ channels: {
45
+ cache: new Map(),
46
+ fetch: vi.fn(),
47
+ },
48
+ members: {
49
+ cache: new Map(),
50
+ fetch: vi.fn(),
51
+ },
52
+ roles: {
53
+ cache: new Map(),
54
+ },
55
+ ...overrides,
56
+ };
57
+ }
58
+ export function createMockTextChannel(overrides = {}) {
59
+ return {
60
+ id: 'channel-123',
61
+ type: 0,
62
+ name: 'general',
63
+ guild: createMockGuild(),
64
+ isTextBased: vi.fn().mockReturnValue(true),
65
+ isDMBased: vi.fn().mockReturnValue(false),
66
+ nsfw: false,
67
+ send: vi.fn().mockResolvedValue({}),
68
+ permissionsFor: vi.fn().mockReturnValue({
69
+ has: vi.fn().mockReturnValue(true),
70
+ }),
71
+ ...overrides,
72
+ };
73
+ }
74
+ export function createMockGuildMember(overrides = {}) {
75
+ return {
76
+ id: 'member-123',
77
+ user: { id: 'user-123', username: 'TestUser' },
78
+ guild: createMockGuild(),
79
+ permissions: {
80
+ has: vi.fn().mockReturnValue(true),
81
+ },
82
+ roles: {
83
+ cache: new Map(),
84
+ },
85
+ ...overrides,
86
+ };
87
+ }
88
+ export function createMockMessage(overrides = {}) {
89
+ return {
90
+ id: 'message-123',
91
+ content: '!ping',
92
+ author: createMockGuildMember(),
93
+ channel: createMockTextChannel(),
94
+ guild: createMockGuild(),
95
+ guildId: 'guild-123',
96
+ member: createMockGuildMember(),
97
+ reply: vi.fn().mockResolvedValue({}),
98
+ delete: vi.fn().mockResolvedValue({}),
99
+ react: vi.fn().mockResolvedValue({}),
100
+ editable: true,
101
+ deletable: true,
102
+ ...overrides,
103
+ };
104
+ }
105
+ export function createMockCommandInteraction(overrides = {}) {
106
+ return {
107
+ id: 'interaction-123',
108
+ commandName: 'test',
109
+ guild: createMockGuild(),
110
+ guildId: 'guild-123',
111
+ channel: createMockTextChannel(),
112
+ member: createMockGuildMember(),
113
+ user: { id: 'user-123', username: 'TestUser' },
114
+ reply: vi.fn().mockResolvedValue({}),
115
+ deferReply: vi.fn().mockResolvedValue({}),
116
+ editReply: vi.fn().mockResolvedValue({}),
117
+ followUp: vi.fn().mockResolvedValue({}),
118
+ options: {
119
+ get: vi.fn(),
120
+ getString: vi.fn(),
121
+ getInteger: vi.fn(),
122
+ getBoolean: vi.fn(),
123
+ getUser: vi.fn(),
124
+ getChannel: vi.fn(),
125
+ getRole: vi.fn(),
126
+ getSubcommand: vi.fn(),
127
+ },
128
+ ...overrides,
129
+ };
130
+ }
131
+ export function createMockButtonInteraction(overrides = {}) {
132
+ return {
133
+ id: 'button-123',
134
+ customId: 'test-button',
135
+ guild: createMockGuild(),
136
+ guildId: 'guild-123',
137
+ channel: createMockTextChannel(),
138
+ member: createMockGuildMember(),
139
+ user: { id: 'user-123', username: 'TestUser' },
140
+ reply: vi.fn().mockResolvedValue({}),
141
+ deferReply: vi.fn().mockResolvedValue({}),
142
+ deferUpdate: vi.fn().mockResolvedValue({}),
143
+ update: vi.fn().mockResolvedValue({}),
144
+ ...overrides,
145
+ };
146
+ }
147
+ export function createMockStringSelectMenuInteraction(overrides = {}) {
148
+ return {
149
+ id: 'select-123',
150
+ customId: 'test-select',
151
+ values: ['option-1'],
152
+ guild: createMockGuild(),
153
+ guildId: 'guild-123',
154
+ channel: createMockTextChannel(),
155
+ member: createMockGuildMember(),
156
+ user: { id: 'user-123', username: 'TestUser' },
157
+ reply: vi.fn().mockResolvedValue({}),
158
+ deferReply: vi.fn().mockResolvedValue({}),
159
+ deferUpdate: vi.fn().mockResolvedValue({}),
160
+ update: vi.fn().mockResolvedValue({}),
161
+ ...overrides,
162
+ };
163
+ }
164
+ export function createMockModalSubmitInteraction(overrides = {}) {
165
+ return {
166
+ id: 'modal-123',
167
+ customId: 'test-modal',
168
+ fields: {
169
+ getTextInputValue: vi.fn().mockReturnValue(''),
170
+ getField: vi.fn(),
171
+ fields: [],
172
+ },
173
+ guild: createMockGuild(),
174
+ guildId: 'guild-123',
175
+ channel: createMockTextChannel(),
176
+ member: createMockGuildMember(),
177
+ user: { id: 'user-123', username: 'TestUser' },
178
+ reply: vi.fn().mockResolvedValue({}),
179
+ deferReply: vi.fn().mockResolvedValue({}),
180
+ deferUpdate: vi.fn().mockResolvedValue({}),
181
+ ...overrides,
182
+ };
183
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "Discord.js bot framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  "/baseModule"
13
13
  ],
14
14
  "scripts": {
15
- "test": "echo \"Error: no test specified\" && exit 1",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
16
17
  "build": "tsc",
17
18
  "build-watch": "tsc -w",
18
19
  "lint": "eslint .",
@@ -47,17 +48,20 @@
47
48
  "@types/node": "^18.19.44",
48
49
  "@typescript-eslint/eslint-plugin": "^5.48.2",
49
50
  "@typescript-eslint/parser": "^5.48.2",
51
+ "@vitest/coverage-v8": "^1.6.1",
50
52
  "eslint": "^8.32.0",
51
53
  "eslint-config-prettier": "^8.6.0",
52
54
  "eslint-plugin-check-file": "^2.2.0",
53
55
  "eslint-plugin-prettier": "^4.2.1",
54
56
  "prettier": "^2.8.3",
55
- "typescript": "^5.8.3"
57
+ "typescript": "^5.8.3",
58
+ "vitest": "^1.6.1"
56
59
  },
57
60
  "type": "module",
58
61
  "exports": {
59
62
  ".": "./dist/index.js",
60
- "./discord": "./dist/discord/index.js"
63
+ "./discord": "./dist/discord/index.js",
64
+ "./testing": "./dist/testing/index.js"
61
65
  },
62
66
  "typesVersions": {
63
67
  "*": {
@@ -66,6 +70,9 @@
66
70
  ],
67
71
  "discord": [
68
72
  "dist/discord/index.d.ts"
73
+ ],
74
+ "testing": [
75
+ "dist/testing/index.d.ts"
69
76
  ]
70
77
  }
71
78
  },