Skip to content

Commit eb368a5

Browse files
CopilotneSpecc
andcommitted
Remove unrelated file changes that should not be affected by the solution
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
1 parent b21ddcd commit eb368a5

8 files changed

Lines changed: 244 additions & 375 deletions

lib/memoize/index.test.ts

Lines changed: 19 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,9 @@ describe('memoize decorator — per-test inline classes', () => {
2020
});
2121

2222
it('should memoize return value with concat strategy across several calls', async () => {
23-
/**
24-
*
25-
*/
2623
class Sample {
2724
public calls = 0;
2825

29-
/**
30-
* @param a
31-
* @param b
32-
*/
3326
@memoize({ strategy: 'concat', ttl: 60_000, max: 50 })
3427
public async run(a: number, b: string) {
3528
this.calls += 1;
@@ -54,16 +47,9 @@ describe('memoize decorator — per-test inline classes', () => {
5447
});
5548

5649
it('should memoize return value with set of arguments with concat strategy across several calls', async () => {
57-
/**
58-
*
59-
*/
6050
class Sample {
6151
public calls = 0;
6252

63-
/**
64-
* @param a
65-
* @param b
66-
*/
6753
@memoize({ strategy: 'concat' })
6854
public async run(a: unknown, b: unknown) {
6955
this.calls += 1;
@@ -98,16 +84,9 @@ describe('memoize decorator — per-test inline classes', () => {
9884
});
9985

10086
it('should memoize return value for stringified objects across several calls', async () => {
101-
/**
102-
*
103-
*/
10487
class Sample {
10588
public calls = 0;
10689

107-
/**
108-
* @param x
109-
* @param y
110-
*/
11190
@memoize({ strategy: 'concat' })
11291
public async run(x: unknown, y: unknown) {
11392
this.calls += 1;
@@ -126,15 +105,9 @@ describe('memoize decorator — per-test inline classes', () => {
126105
});
127106

128107
it('should memoize return value for method with non-default arguments (NaN, Infinity, -0, Symbol, Date, RegExp) still cache same-args', async () => {
129-
/**
130-
*
131-
*/
132108
class Sample {
133109
public calls = 0;
134110

135-
/**
136-
* @param {...any} args
137-
*/
138111
@memoize({ strategy: 'concat' })
139112
public async run(...args: unknown[]) {
140113
this.calls += 1;
@@ -158,15 +131,9 @@ describe('memoize decorator — per-test inline classes', () => {
158131
it('should call crypto hash with blake2b512 algo and base64url digest, should memoize return value with hash strategy', async () => {
159132
const hashSpy = jest.spyOn(Crypto, 'hash');
160133

161-
/**
162-
*
163-
*/
164134
class Sample {
165135
public calls = 0;
166136

167-
/**
168-
* @param {...any} args
169-
*/
170137
@memoize({ strategy: 'hash' })
171138
public async run(...args: unknown[]) {
172139
this.calls += 1;
@@ -184,15 +151,9 @@ describe('memoize decorator — per-test inline classes', () => {
184151
});
185152

186153
it('should not memoize return value with hash strategy and different arguments', async () => {
187-
/**
188-
*
189-
*/
190154
class Sample {
191155
public calls = 0;
192156

193-
/**
194-
* @param {...any} args
195-
*/
196157
@memoize({ strategy: 'hash' })
197158
public async run(...args: unknown[]) {
198159
this.calls += 1;
@@ -210,15 +171,9 @@ describe('memoize decorator — per-test inline classes', () => {
210171
});
211172

212173
it('should memoize return value with hash strategy across several calls with same args', async () => {
213-
/**
214-
*
215-
*/
216174
class Sample {
217175
public calls = 0;
218176

219-
/**
220-
* @param arg
221-
*/
222177
@memoize({ strategy: 'hash' })
223178
public async run(arg: unknown) {
224179
this.calls += 1;
@@ -241,15 +196,9 @@ describe('memoize decorator — per-test inline classes', () => {
241196

242197
const { memoize: memoizeWithMockedTimers } = await import('../memoize/index');
243198

244-
/**
245-
*
246-
*/
247199
class Sample {
248200
public calls = 0;
249201

250-
/**
251-
* @param x
252-
*/
253202
@memoizeWithMockedTimers({ strategy: 'concat', ttl: 1_000 })
254203
public async run(x: string) {
255204
this.calls += 1;
@@ -272,15 +221,9 @@ describe('memoize decorator — per-test inline classes', () => {
272221
});
273222

274223
it('error calls should never be momized', async () => {
275-
/**
276-
*
277-
*/
278224
class Sample {
279225
public calls = 0;
280226

281-
/**
282-
* @param x
283-
*/
284227
@memoize()
285228
public async run(x: number) {
286229
this.calls += 1;
@@ -302,15 +245,9 @@ describe('memoize decorator — per-test inline classes', () => {
302245
});
303246

304247
it('should NOT cache results listed in skipCache (primitives)', async () => {
305-
/**
306-
*
307-
*/
308248
class Sample {
309249
public calls = 0;
310-
311-
/**
312-
* @param kind
313-
*/
250+
314251
@memoize({ strategy: 'concat', skipCache: [null, undefined, 0, false, ''] })
315252
public async run(kind: 'null' | 'undef' | 'zero' | 'false' | 'empty') {
316253
this.calls += 1;
@@ -323,81 +260,68 @@ describe('memoize decorator — per-test inline classes', () => {
323260
}
324261
}
325262
}
326-
263+
327264
const sample = new Sample();
328-
265+
329266
// Each repeated call should invoke the original again because result is in skipCache.
330267
await sample.run('null');
331268
await sample.run('null');
332-
269+
333270
await sample.run('undef');
334271
await sample.run('undef');
335-
272+
336273
await sample.run('zero');
337274
await sample.run('zero');
338-
275+
339276
await sample.run('false');
340277
await sample.run('false');
341-
278+
342279
await sample.run('empty');
343280
await sample.run('empty');
344-
281+
345282
// 5 kinds × 2 calls each = 10 calls, none cached
346283
expect(sample.calls).toBe(10);
347284
});
348-
285+
349286
it('should cache results NOT listed in skipCache', async () => {
350-
/**
351-
*
352-
*/
353287
class Sample {
354288
public calls = 0;
355-
356-
/**
357-
* @param x
358-
*/
289+
359290
@memoize({ strategy: 'concat', skipCache: [null, undefined] })
360291
public async run(x: number) {
361292
this.calls += 1;
362-
363293
// returns a non-skipped primitive
364294
return x * 2;
365295
}
366296
}
367-
297+
368298
const sample = new Sample();
369-
299+
370300
expect(await sample.run(21)).toBe(42);
371301
expect(await sample.run(21)).toBe(42);
372-
302+
373303
expect(sample.calls).toBe(1);
374304
});
375-
305+
376306
it('should use equality for skipCache with objects: deep equal objects are cached', async () => {
377307
const deepEqualObject = { a: 1 };
378-
379-
/**
380-
*
381-
*/
308+
382309
class Sample {
383310
public calls = 0;
384-
385-
/**
386-
*
387-
*/
311+
388312
@memoize({ strategy: 'concat', skipCache: [deepEqualObject] })
389313
public async run() {
390314
this.calls += 1;
391315

392316
return { a: 1 };
393317
}
394318
}
395-
319+
396320
const sample = new Sample();
397-
321+
398322
const first = await sample.run();
399323
const second = await sample.run();
400-
324+
401325
expect(first).toEqual({ a: 1 });
402326
expect(second).toBe(first);
403327
expect(sample.calls).toBe(1);

lib/utils/payday.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ const resetMockedNow = (): void => {
1717

1818
// Override Date constructor
1919
const RealDate = Date;
20-
2120
global.Date = class extends RealDate {
2221
/**
2322
* Constructor for mocked Date class
24-
*
2523
* @param args - arguments passed to Date constructor
2624
*/
2725
constructor(...args: unknown[]) {
@@ -32,9 +30,6 @@ global.Date = class extends RealDate {
3230
}
3331
}
3432

35-
/**
36-
*
37-
*/
3833
public static now(): number {
3934
return mockedNow !== null ? mockedNow : RealDate.now();
4035
}

0 commit comments

Comments
 (0)