Skip to content

Commit 16ea57a

Browse files
committed
minor test cleanup for express middleware and eslint config change.
1 parent 6a55933 commit 16ea57a

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
},
2020
"plugins": ["import", "prettier"],
2121
"rules": {
22-
22+
"no-plusplus": [2, {
23+
"allowForLoopAfterthoughts": "true"
24+
}],
2325
"prettier/prettier": [
2426
"error"
2527
]

test/middleware/express.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ describe('Express Middleware tests', () => {
220220

221221
middleware(mockRequest as Request, mockResponse as Response, nextFunction);
222222

223-
// We don't actually call json
224-
expect(mockResponse.json).toBeCalledWith(expectedResponse);
225223
expect(mockResponse.locals).toHaveProperty('complexity');
226224
expect(mockResponse.locals?.complexity).toBeInstanceOf('number');
227225
expect(mockResponse.locals?.complexity).toBeGreaterThanOrEqual(0);
@@ -290,11 +288,9 @@ describe('Express Middleware tests', () => {
290288
`,
291289
},
292290
};
293-
const expectedResponse = {
294-
status: 429,
295-
};
296291

297292
middleware(mockRequest as Request, mockResponse as Response, nextFunction);
293+
// FIXME: status is a function. Where does 439 actaully get set.
298294
expect(mockResponse.status).toBe(429);
299295
expect(nextFunction).not.toBeCalled();
300296

@@ -327,7 +323,6 @@ describe('Express Middleware tests', () => {
327323
test('Uses User IP Address in Redis', async () => {
328324
const client: RedisClientType = redis.createClient();
329325
// Check for change in the redis store for the IP key
330-
if (!mockRequest.ip) throw new Error('Expected ip to exist on mockRequest');
331326
const initialValue: string | null = await client.get(mockRequest?.ip);
332327

333328
middleware(mockRequest as Request, mockResponse as Response, nextFunction);

0 commit comments

Comments
 (0)