mirror of
https://github.com/standardnotes/server
synced 2026-01-16 20:04:32 -05:00
33 lines
927 B
TypeScript
33 lines
927 B
TypeScript
import 'reflect-metadata'
|
|
|
|
import * as IORedis from 'ioredis'
|
|
|
|
import { RedisDomainEventPublisher } from './RedisDomainEventPublisher'
|
|
import { DomainEventInterface } from '@standardnotes/domain-events'
|
|
|
|
describe('RedisDomainEventPublisher', () => {
|
|
let redisClient: IORedis.Redis
|
|
let event: DomainEventInterface
|
|
const eventChannel = 'events'
|
|
|
|
const createPublisher = () => new RedisDomainEventPublisher(redisClient, eventChannel)
|
|
|
|
beforeEach(() => {
|
|
redisClient = {} as jest.Mocked<IORedis.Redis>
|
|
redisClient.publish = jest.fn()
|
|
|
|
event = {} as jest.Mocked<DomainEventInterface>
|
|
event.type = 'TEST'
|
|
event.payload = { foo: 'bar' }
|
|
})
|
|
|
|
it('should publish an event to a channel', async () => {
|
|
await createPublisher().publish(event)
|
|
|
|
expect(redisClient.publish).toHaveBeenCalledWith(
|
|
'events',
|
|
'eJyrViqpLEhVslIKcQ0OUdJRKkiszMlPTFGyqlZKy89XslJKSixSqq0FAPbUDIQ=',
|
|
)
|
|
})
|
|
})
|