improved test

pull/12110/head
FoHoOV 2 years ago
parent 7df85f4d0e
commit dc55523b14

@ -14,10 +14,12 @@ export class ReactiveDate extends Date {
#signals = new Map(); #signals = new Map();
/** /**
* @param {ConstructorParameters<typeof Date>} params * @param {any[]} params
*/ */
constructor(...params) { constructor(...params) {
// @ts-ignore
super(...params); super(...params);
// @ts-ignore
this.#modified_date_to_compare = new Date(...params); this.#modified_date_to_compare = new Date(...params);
this.#init(); this.#init();
} }
@ -140,7 +142,16 @@ export class ReactiveDate extends Date {
} }
if (is_time_changed || is_date_changed) { if (is_time_changed || is_date_changed) {
this.#increment_signal('getTimezoneOffset', 'getTime'); this.#increment_signal(
'getTimezoneOffset',
'getTime',
'toDateString',
'toISOString',
'toLocaleString',
'toJSON',
'toUTCString',
'toString'
);
} }
} }

@ -582,7 +582,7 @@ test('Date propagated changes', () => {
cleanup(); cleanup();
}); });
test('date fine grained tests', () => { test('Date fine grained tests', () => {
const date = new ReactiveDate(initial_date); const date = new ReactiveDate(initial_date);
let changes: Record<string, boolean> = { let changes: Record<string, boolean> = {
@ -601,7 +601,13 @@ test('date fine grained tests', () => {
getSeconds: true, getSeconds: true,
getUTCSeconds: true, getUTCSeconds: true,
getMilliseconds: true, getMilliseconds: true,
getUTCMilliseconds: true getUTCMilliseconds: true,
getTime: true,
toISOString: true,
toJSON: true,
toUTCString: true,
toString: true,
toLocaleString: true
}; };
let test_description: string = ''; let test_description: string = '';
@ -631,7 +637,13 @@ test('date fine grained tests', () => {
getMonth: true, getMonth: true,
getUTCMonth: true, getUTCMonth: true,
getDay: true, getDay: true,
getUTCDay: true getUTCDay: true,
getTime: true,
toISOString: true,
toJSON: true,
toUTCString: true,
toString: true,
toLocaleString: true
}; };
test_description = 'changing setFullYear that will cause month/day change as well'; test_description = 'changing setFullYear that will cause month/day change as well';
date.setFullYear(initial_date.getFullYear() + 1, initial_date.getMonth() + 1); date.setFullYear(initial_date.getFullYear() + 1, initial_date.getMonth() + 1);
@ -652,7 +664,13 @@ test('date fine grained tests', () => {
getSeconds: true, getSeconds: true,
getUTCSeconds: true, getUTCSeconds: true,
getMilliseconds: true, getMilliseconds: true,
getUTCMilliseconds: true getUTCMilliseconds: true,
getTime: true,
toISOString: true,
toJSON: true,
toUTCString: true,
toString: true,
toLocaleString: true
}; };
test_description = 'changing seconds that will change day/hour/minutes/seconds/milliseconds'; test_description = 'changing seconds that will change day/hour/minutes/seconds/milliseconds';
date.setSeconds(61 * 60 * 25 + 1, 10); date.setSeconds(61 * 60 * 25 + 1, 10);
@ -667,7 +685,13 @@ test('date fine grained tests', () => {
getDay: true, getDay: true,
getUTCDay: true, getUTCDay: true,
getMilliseconds: true, getMilliseconds: true,
getUTCMilliseconds: true getUTCMilliseconds: true,
getTime: true,
toISOString: true,
toJSON: true,
toUTCString: true,
toString: true,
toLocaleString: true
}; };
test_description = 'changing month'; test_description = 'changing month';
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);

@ -2123,7 +2123,7 @@ declare module 'svelte/motion' {
declare module 'svelte/reactivity' { declare module 'svelte/reactivity' {
class ReactiveDate extends Date { class ReactiveDate extends Date {
constructor(...values: any[]); constructor(...params: any[]);
#private; #private;
} }
class ReactiveSet<T> extends Set<T> { class ReactiveSet<T> extends Set<T> {

Loading…
Cancel
Save