import { generate_token_id, parse_token_id } from '../../lib/token_id'; import { clock_finalize, clock_setup } from '../Helper'; describe ('token_id', () => { beforeAll (() => { clock_setup (); }); afterAll (() => { clock_finalize (); }); it ('should always generate valid tokens', () => { for (let i = 0; i < 1000; i++) { const date = new Date; const token_id = generate_token_id (new Date); const parsed = parse_token_id (token_id); expect (parsed.valid_until) .toEqual (date); } }); });