first commit
This commit is contained in:
23
libs/web/identity/domain/src/lib/session.spec.ts
Normal file
23
libs/web/identity/domain/src/lib/session.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { isExpired, sessionFrom } from './session';
|
||||
|
||||
describe('session', () => {
|
||||
it('computes the expiry from expires_in', () => {
|
||||
const session = sessionFrom(
|
||||
{ accessToken: 't', refreshToken: 'r', expiresIn: 3600 },
|
||||
1_000,
|
||||
);
|
||||
expect(session).toEqual({
|
||||
accessToken: 't',
|
||||
refreshToken: 'r',
|
||||
expiresAt: 3_601_000,
|
||||
});
|
||||
});
|
||||
|
||||
it('treats tokens about to expire as expired', () => {
|
||||
const session = sessionFrom({ accessToken: 't', expiresIn: 30 }, 0);
|
||||
expect(isExpired(session, 0)).toBe(true);
|
||||
expect(
|
||||
isExpired(sessionFrom({ accessToken: 't', expiresIn: 3600 }, 0), 0),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user