Skip to content

Commit 82bd25b

Browse files
committed
refactoring middleware tests to use ioredis
1 parent b6a7c0a commit 82bd25b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/middleware/express.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Request, Response, NextFunction, RequestHandler } from 'express';
22
import { GraphQLSchema, buildSchema } from 'graphql';
3-
import * as redis from 'redis';
4-
import redisMock from 'redis-mock';
5-
import { RedisClientType } from 'redis';
3+
import * as ioredis from 'ioredis';
4+
65
import expressRateLimitMiddleware from '../../src/middleware/index';
76

7+
// eslint-disable-next-line @typescript-eslint/no-var-requires
8+
const RedisMock = require('ioredis-mock');
9+
810
let middleware: RequestHandler;
911
let mockRequest: Partial<Request>;
1012
let complexRequest: Partial<Request>;
@@ -337,7 +339,7 @@ xdescribe('Express Middleware tests', () => {
337339
// We could use NODE_ENV varibale in the implementation to determine the connection type.
338340

339341
// TODO: connect to the actual redis client here. Make sure to disconnect for proper teardown
340-
const client: RedisClientType = redisMock.createClient();
342+
const client: ioredis.Redis = new RedisMock();
341343
await client.connect();
342344
// Check for change in the redis store for the IP key
343345

0 commit comments

Comments
 (0)