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

Commit 35b11e3

Browse files
committed
Fix tests around loggedInNavGuard
1 parent 60231e3 commit 35b11e3

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/router/loggedInNavGuard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export default async function (to, from, next) {
1515
return null;
1616
}
1717

18-
next();
18+
next(undefined);
1919
return null;
2020
}

test/unit/specs/router/loggedInNavGuard.spec.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ describe('loggedInNavGuard', () => {
1717

1818
it('should continue to the route if the user is logged in', async () => {
1919
// ARRANGE
20-
MockUserService.getCurrentUser.resolves({ body: { login: { token: 'blah' } } });
20+
MockUserService.getCurrentUser.resolves({
21+
body: {
22+
login: { token: 'blah' },
23+
user: { termsConditionsAccepted: true },
24+
},
25+
});
2126

2227
// ACT
2328
await loggedInNavGuardWithMock({}, {}, nextMock);
@@ -44,4 +49,26 @@ describe('loggedInNavGuard', () => {
4449
query: { referer: '/some/path' },
4550
});
4651
});
52+
53+
it('should redirect to profile page if user has not accepted terms and conditions', async () => {
54+
// ARRANGE
55+
MockUserService.getCurrentUser.resolves({
56+
body: {
57+
login: { token: 'blah' },
58+
user: { id: 'userid', termsConditionsAccepted: false },
59+
},
60+
});
61+
const toMock = {
62+
fullPath: '/some/path',
63+
};
64+
65+
// ACT
66+
await loggedInNavGuardWithMock(toMock, {}, nextMock);
67+
68+
// ASSERT
69+
expect(nextMock).to.have.been.calledOnce;
70+
expect(nextMock).to.have.been.calledWith({
71+
path: '/dashboard/profile/userid/edit',
72+
});
73+
});
4774
});

0 commit comments

Comments
 (0)