fix: use explicit super args for MockDate constructors

This commit is contained in:
2026-03-28 00:09:25 -07:00
parent 90a9147363
commit 615625d215

View File

@@ -793,9 +793,13 @@ test('getTrendsDashboard month grouping spans every touched calendar month and k
const RealDate = Date;
class MockDate extends Date {
constructor(...args: ConstructorParameters<typeof Date>) {
const resolvedArgs = args.length === 0 ? [new RealDate(2026, 2, 1, 12, 0, 0).getTime()] : args;
return Reflect.construct(RealDate, resolvedArgs, new.target) as this;
constructor(...args: any[]) {
type MockDateArgs = [any, any, any, any, any, any, any];
if (args.length === 0) {
super(new RealDate(2026, 2, 1, 12, 0, 0).getTime());
} else {
super(...(args as MockDateArgs));
}
}
static override now(): number {
@@ -1066,9 +1070,13 @@ test('getQueryHints computes weekly new-word cutoff from calendar midnights', ()
const RealDate = Date;
class MockDate extends Date {
constructor(...args: ConstructorParameters<typeof Date>) {
const resolvedArgs = args.length === 0 ? [new RealDate(2026, 2, 15, 12, 0, 0).getTime()] : args;
return Reflect.construct(RealDate, resolvedArgs, new.target) as this;
constructor(...args: any[]) {
type MockDateArgs = [any, any, any, any, any, any, any];
if (args.length === 0) {
super(new RealDate(2026, 2, 15, 12, 0, 0).getTime());
} else {
super(...(args as MockDateArgs));
}
}
static override now(): number {