test(HH-592): cover realtime timestamp boundaries (#153)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user