Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Releases: HugoDF/mock-express-request-response

Setup simple authentication application

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:16
setup

implement client-sessions-based (cookie) authentication app + sample …

Mock/stub Express request/response

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:17
mock-request-response

add mock request/response with jest and sinon

Tests for a middleware that consumes headers

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:58

Adds tests for headerAuthMiddleware.

An example of testing a middleware and of mocking .get('header-name') on Express requests.

logout tests

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:21

Adds tests for logout route handler.

Route resets contents of req.session.data and 200s. Example of testing a write to a field on req (or res)

login tests

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:23

Adds tests for login route handler.

Adds a body param for mockRequest since login reads from the body (which is actually provided by the body-parser middleware).

checkAuth tests

Choose a tag to compare

@HugoDF HugoDF released this 17 Feb 19:17

Adds tests for checkAuth route handler using previously defined mockRequest and mockResponse.

The route just reads from res.session.data and depending on the contents of the session, 401s (session is empty/invalid) or 200s with part of the contents of it.