mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: @discordjs/brokers (#8548)
This commit is contained in:
18
packages/brokers/__tests__/index.test.ts
Normal file
18
packages/brokers/__tests__/index.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type Redis from 'ioredis';
|
||||
import { test, expect, vi } from 'vitest';
|
||||
import { PubSubRedisBroker } from '../src/index.js';
|
||||
|
||||
const mockRedisClient = {
|
||||
defineCommand: vi.fn(),
|
||||
xadd: vi.fn(),
|
||||
duplicate: vi.fn(() => mockRedisClient),
|
||||
} as unknown as Redis;
|
||||
|
||||
test('pubsub with custom encoding', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
const encode = vi.fn((data) => data);
|
||||
|
||||
const broker = new PubSubRedisBroker({ redisClient: mockRedisClient, encode });
|
||||
await broker.publish('test', 'test');
|
||||
expect(encode).toHaveBeenCalledWith('test');
|
||||
});
|
||||
Reference in New Issue
Block a user