test(HH-592): cover realtime timestamp boundaries (#153)

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-24 11:13:53 +08:00
committed by GitHub
co-authored by rogee
parent 2c6bee2b37
commit 92ace6b041
3 changed files with 27 additions and 10 deletions
@@ -23,12 +23,29 @@ afterEach(() => {
describe('#isNewerTimestamp', () => {
it.each([
['Unix seconds', 1_700_000_000, 1_700_000_001],
['numeric strings', '1700000000', '1700000001'],
['early Unix milliseconds', 978_307_200_000, 1_700_000_000],
['below the former 1e12 threshold', 999_999_999_999, 1_000_000_000_000],
])('orders %s', (_label, current, next) => {
expect(isNewerTimestamp(current, next)).toBe(true);
['Unix seconds', 1_700_000_000, 1_700_000_001, true],
['numeric strings', '1700000000', '1700000001', true],
['early Unix milliseconds', 978_307_200_000, 1_700_000_000, true],
[
'below the former 1e12 threshold',
999_999_999_999,
1_000_000_000_000,
true,
],
['below 1e10 as seconds', 9_999_999_998, 9_999_999_999, true],
['1e10 as milliseconds', 9_999_999_999, 10_000_000_000, false],
['above 1e10 as milliseconds', 10_000_000_000, 10_000_000_001, true],
['minimum ECMAScript Date', 'invalid', -8_640_000_000_000_000, true],
['below minimum Date', 'invalid', -8_640_000_000_000_001, false],
[
'maximum ECMAScript Date',
8_639_999_999_999_999,
8_640_000_000_000_000,
true,
],
['above maximum Date', 8_639_999_999_999_999, 8_640_000_000_000_001, false],
])('handles %s', (_label, current, next, expected) => {
expect(isNewerTimestamp(current, next)).toBe(expected);
});
it('preserves missing and invalid timestamp compatibility', () => {