Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:

strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
redis-tag: [7.2, 7.4]
node-version: [20.x, 22.x, 24.x, 26.x]
redis-tag: [7, 8]
services:
redis:
image: redis:${{ matrix.redis-tag }}
ports:
- 6379:6379
- 6379:6379
options: --entrypoint redis-server

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}

Expand Down
50 changes: 0 additions & 50 deletions mqemitter-redis.test-d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "7.2.0",
"description": "Redis-based MQEmitter",
"main": "mqemitter-redis.js",
"types": "mqemitter-redis.d.ts",
"types": "types/mqemitter-redis.d.ts",
"engines": {
"node": ">=20"
},
Expand All @@ -20,15 +20,15 @@
"@types/node": "^24.0.14",
"eslint": "^9.24.0",
"neostandard": "^0.12.1",
"tsd": "^0.33.0"
"tstyche": "^7.2.1"
},
"scripts": {
"lint:fix": "eslint --fix",
"lint": "eslint",
"unit": "node --test --test-concurrency=1 test/*.js",
"test:types": "tsd",
"test:types": "tstyche",
"typescript": "tsc --project ./test/types/tsconfig.json",
"test": "npm run lint && npm run unit && tsd",
"test": "npm run lint && npm run unit && tstyche",
"redis": "docker run -d --rm --name redis -p 6379:6379 redis:7"
},
"pre-commit": "test",
Expand Down
File renamed without changes.
79 changes: 79 additions & 0 deletions types/mqemitter-redis.tst.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { describe, expect, it } from 'tstyche'
import mqEmitterRedis, { Message, MQEmitterRedis } from './mqemitter-redis.js'

describe('MQEmitterRedis', () => {
describe('constructor', () => {
it('returns MQEmitterRedis with no options', () => {
expect(mqEmitterRedis()).type.toBe<MQEmitterRedis>()
})

it('returns MQEmitterRedis with simple options', () => {
expect(
mqEmitterRedis({ concurrency: 200, matchEmptyLevels: true })
).type.toBe<MQEmitterRedis>()
})

it('returns MQEmitterRedis with full options', () => {
expect(
mqEmitterRedis({
concurrency: 10,
matchEmptyLevels: true,
separator: '/',
wildcardOne: '+',
wildcardSome: '#',
connectionString: 'redis://:authpassword@127.0.0.1:6380/4',
})
).type.toBe<MQEmitterRedis>()
})

it('returns MQEmitterRedis with ioredis options', () => {
expect(
mqEmitterRedis({
concurrency: 10,
matchEmptyLevels: true,
host: 'localhost',
port: 6379,
reconnectOnError: (_error: Error) => true,
retryStrategy: (times: number) => times * 1.5,
})
).type.toBe<MQEmitterRedis>()
})

it('returns MQEmitterRedis with LRU cache options', () => {
expect(
mqEmitterRedis({
maxLRUCache: 100,
ttlLRUCache: 10000,
})
).type.toBe<MQEmitterRedis>()
})
})

describe('methods', () => {
function listener (_message: Message, _done: () => void) {}

it('on returns the instance', () => {
expect(mqEmitterRedis().on('topic', listener)).type.toBe<MQEmitterRedis>()
})

it('removeListener returns void', () => {
expect(
mqEmitterRedis().removeListener('topic', listener)
).type.toBe<void>()
})

it('emit rejects null', () => {
expect(mqEmitterRedis().emit).type.not.toBeCallableWith(null)
})

it('emit returns void', () => {
expect(
mqEmitterRedis().emit({ topic: 'test', prop1: 'prop1' })
).type.toBe<void>()
})

it('close returns void', () => {
expect(mqEmitterRedis().close(() => null)).type.toBe<void>()
})
})
})