Files
discord.js/packages/brokers/__tests__/index.test.ts
DD e7cbc1bf11 fix(BaseRedisBroker): proper import path to lua script (#8776)
* fix(BaseRedisBroker): proper import path to lua script

* chore: fix tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-10-27 19:47:00 +00:00

25 lines
660 B
TypeScript

import type Redis from 'ioredis';
import { test, expect, vi } from 'vitest';
import { PubSubRedisBroker } from '../src/index.js';
vi.mock('node:fs', () => {
return {
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 () => {
// 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');
});