Skip to content

Commit

Permalink
Handle enabling renewals for users without an expiration date
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroquem committed Aug 6, 2021
1 parent d8964c6 commit 00a5222
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@ export function getValue(value) {
// Given a user record, test whether the user is active. Checking the `active` property ought to
// be sufficient, but test the expiration date as well just to be sure.
export function checkUserActive(user) {
if (user.expirationDate == null || user.expirationDate == undefined) return user.active;
return user.active && (new Date(user.expirationDate) >= new Date());
}
10 changes: 10 additions & 0 deletions src/components/util/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ describe('checkUserActive', () => {

expect(checkUserActive(user)).toBe(false);
});

it('returns true for active users without an expiration date', () => {
const expDate = new Date();
const user = {
active: true,
expirationDate: undefined,
};

expect(checkUserActive(user)).toBe(true);
});
});

0 comments on commit 00a5222

Please sign in to comment.