|
|
@@ -14,11 +14,6 @@ describe('loginRequired', () => {
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
- // test('returns strict middlware when args is undefined', () => {
|
|
|
- // const func = middlewares.loginRequired();
|
|
|
- // expect(func).toBe(loginRequiredStrict);
|
|
|
- // });
|
|
|
-
|
|
|
describe('not strict mode', () => {
|
|
|
// setup req/res/next
|
|
|
const req = {
|
|
|
@@ -134,21 +129,21 @@ describe('loginRequired', () => {
|
|
|
${3} | ${'/login/error/suspended'}
|
|
|
${5} | ${'/login/invited'}
|
|
|
`('redirect to \'$expectedPath\' when user.status is \'$userStatus\'', ({ userStatus, expectedPath }) => {
|
|
|
- req.user = {
|
|
|
- _id: 'user id',
|
|
|
- status: userStatus,
|
|
|
- };
|
|
|
-
|
|
|
- const result = loginRequiredStrictly(req, res, next);
|
|
|
-
|
|
|
- expect(isGuestAllowedToReadSpy).not.toHaveBeenCalled();
|
|
|
- expect(next).not.toHaveBeenCalled();
|
|
|
- expect(res.sendStatus).not.toHaveBeenCalled();
|
|
|
- expect(res.redirect).toHaveBeenCalledTimes(1);
|
|
|
- expect(res.redirect).toHaveBeenCalledWith(expectedPath);
|
|
|
- expect(result).toBe('redirect');
|
|
|
- expect(req.session.jumpTo).toBe(undefined);
|
|
|
- });
|
|
|
+ req.user = {
|
|
|
+ _id: 'user id',
|
|
|
+ status: userStatus,
|
|
|
+ };
|
|
|
+
|
|
|
+ const result = loginRequiredStrictly(req, res, next);
|
|
|
+
|
|
|
+ expect(isGuestAllowedToReadSpy).not.toHaveBeenCalled();
|
|
|
+ expect(next).not.toHaveBeenCalled();
|
|
|
+ expect(res.sendStatus).not.toHaveBeenCalled();
|
|
|
+ expect(res.redirect).toHaveBeenCalledTimes(1);
|
|
|
+ expect(res.redirect).toHaveBeenCalledWith(expectedPath);
|
|
|
+ expect(result).toBe('redirect');
|
|
|
+ expect(req.session.jumpTo).toBe(undefined);
|
|
|
+ });
|
|
|
/* eslint-disable indent */
|
|
|
|
|
|
test('redirect to \'/login\' when user.status is \'STATUS_DELETED\'', () => {
|