Skip to content

Commit c8e7a45

Browse files
committed
changes from testing
1 parent dd90275 commit c8e7a45

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

cache/__tests__/cache.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,11 @@ describe('Cache Middleware Tests', () => {
365365
cacheStats(mockReq, mockRes)
366366

367367
expect(mockRes.json).toHaveBeenCalled()
368-
const stats = mockRes.json.mock.calls[0][0]
369-
expect(stats).toHaveProperty('stats')
370-
expect(stats.stats).toHaveProperty('hits')
371-
expect(stats.stats).toHaveProperty('misses')
372-
expect(stats.stats).toHaveProperty('hitRate')
373-
expect(stats.stats).toHaveProperty('length')
368+
const response = mockRes.json.mock.calls[0][0]
369+
expect(response).toHaveProperty('hits')
370+
expect(response).toHaveProperty('misses')
371+
expect(response).toHaveProperty('hitRate')
372+
expect(response).toHaveProperty('length')
374373
})
375374

376375
it('should include details when requested', () => {
@@ -380,6 +379,8 @@ describe('Cache Middleware Tests', () => {
380379

381380
const response = mockRes.json.mock.calls[0][0]
382381
expect(response).toHaveProperty('details')
382+
expect(response).toHaveProperty('hits')
383+
expect(response).toHaveProperty('misses')
383384
})
384385
})
385386

cache/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ const invalidateCache = (req, res, next) => {
470470
*/
471471
const cacheStats = (req, res) => {
472472
const stats = cache.getStats()
473-
const response = { stats }
473+
const response = { ...stats }
474474
if (req.query.details === 'true') response.details = cache.getDetailsByEntry()
475475
res.status(200).json(response)
476476
}

0 commit comments

Comments
 (0)