Files
discord.js/packages/brokers/__tests__/index.test.ts
Almeida 5888663392 test: fix type errors (#11325)
* test: fix type errors

* chore: use MockedFunction

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2025-12-08 00:24:29 +00:00

22 lines
599 B
TypeScript

import type Redis from 'ioredis';
import { test, expect, vi } from 'vitest';
import { PubSubRedisBroker } from '../src/index.js';
vi.mock('node:fs', () => ({
readFileSync: vi.fn(),
}));
const mockRedisClient = {
defineCommand: vi.fn(),
xadd: vi.fn(),
duplicate: vi.fn(() => mockRedisClient),
} as unknown as Redis;
test('pubsub with custom encoding', async () => {
const encode = vi.fn((data) => data);
const broker = new PubSubRedisBroker(mockRedisClient, { encode, name: 'yeet', group: 'group' });
await broker.publish('test', 'test');
expect(encode).toHaveBeenCalledWith('test');
});