Skip to content

Commit f62820d

Browse files
committed
middleware test fix
1 parent 42463ae commit f62820d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

server/middleware/auth.middleware.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ test('block on incorrect token', done => {
2727
}
2828
}
2929

30-
const next = () => {
31-
throw new Error('next')
32-
done()
33-
}
30+
const next = jest.fn()
31+
32+
authMiddleware(req, res, next)
3433

35-
expect(() => authMiddleware(req, res, next)).not.toThrow('next')
34+
expect(next).not.toHaveBeenCalled()
3635
})

server/middleware/https.middleware.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ test('correct redirect', done => {
2626
}
2727
}
2828

29-
const next = done
29+
const next = jest.fn()
3030

3131
httpsMiddleware(req, res, next)
32+
33+
expect(next).not.toHaveBeenCalled()
3234
})

0 commit comments

Comments
 (0)