Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Created October 2, 2018 11:12
Show Gist options
  • Save tsh-code/cf8589513838deeb0bfcf4eeda18121c to your computer and use it in GitHub Desktop.
Save tsh-code/cf8589513838deeb0bfcf4eeda18121c to your computer and use it in GitHub Desktop.
test('tokenExpired', () => {
const token = { token: '123-abc-123', expirationDate: new Date('2018-01-01T12:00:00.000Z') };
const timeBeforeTokenExpiration = new Date('2018-01-01T11:59:00.000Z');
const timeAfterTokenExpiration = new Date('2018-01-01T12:01:00.000Z');
expect(tokenExpired(token, timeBeforeTokenExpiration)).toBe(false);
expect(tokenExpired(token, timeAfterTokenExpiration)).toBe(true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment