chore:little fixes and formating and linting and patches
This commit is contained in:
@@ -9,8 +9,8 @@ describe('cachable', () => {
|
||||
redis = getRedisCache();
|
||||
// Clear any existing cache data for clean tests
|
||||
const keys = [
|
||||
...await redis.keys('cachable:*'),
|
||||
...await redis.keys('test-key*'),
|
||||
...(await redis.keys('cachable:*')),
|
||||
...(await redis.keys('test-key*')),
|
||||
];
|
||||
if (keys.length > 0) {
|
||||
await redis.del(...keys);
|
||||
@@ -20,8 +20,8 @@ describe('cachable', () => {
|
||||
afterEach(async () => {
|
||||
// Clean up after each test
|
||||
const keys = [
|
||||
...await redis.keys('cachable:*'),
|
||||
...await redis.keys('test-key*'),
|
||||
...(await redis.keys('cachable:*')),
|
||||
...(await redis.keys('test-key*')),
|
||||
];
|
||||
if (keys.length > 0) {
|
||||
await redis.del(...keys);
|
||||
@@ -139,7 +139,7 @@ describe('cachable', () => {
|
||||
const cachedFn = cacheable(
|
||||
'testFunction',
|
||||
async (arg1: string, arg2: string) => mockData,
|
||||
3600,
|
||||
3600
|
||||
);
|
||||
await cachedFn('arg1', 'arg2');
|
||||
|
||||
@@ -354,7 +354,7 @@ describe('cachable', () => {
|
||||
const cachedFn = cacheable(
|
||||
'testFunction',
|
||||
async (arg1: string) => mockData,
|
||||
3600,
|
||||
3600
|
||||
);
|
||||
const key = cachedFn.getKey('arg1');
|
||||
await redis.set(key, 'invalid json');
|
||||
@@ -376,7 +376,7 @@ describe('cachable', () => {
|
||||
expect(fnCalled).toBe(true);
|
||||
expect(consoleSpy).toHaveBeenCalledWith(
|
||||
'Failed to parse cache',
|
||||
expect.any(Error),
|
||||
expect.any(Error)
|
||||
);
|
||||
|
||||
consoleSpy.mockRestore();
|
||||
@@ -390,7 +390,7 @@ describe('cachable', () => {
|
||||
const cachedFn = cacheable(
|
||||
'testFunction',
|
||||
async (arg1: string) => cachedData,
|
||||
3600,
|
||||
3600
|
||||
);
|
||||
await cachedFn('arg1');
|
||||
|
||||
@@ -478,7 +478,7 @@ describe('cachable', () => {
|
||||
arg5: undefined,
|
||||
arg6: number[],
|
||||
arg7: { a: number; b: number },
|
||||
arg8: Date,
|
||||
arg8: Date
|
||||
) => ({});
|
||||
const cachedFn = cacheable(fn, 3600);
|
||||
|
||||
@@ -490,7 +490,7 @@ describe('cachable', () => {
|
||||
undefined,
|
||||
[1, 2, 3],
|
||||
{ a: 1, b: 2 },
|
||||
new Date('2023-01-01T00:00:00Z'),
|
||||
new Date('2023-01-01T00:00:00Z')
|
||||
);
|
||||
|
||||
expect(key).toMatch(/^cachable:.*:/);
|
||||
|
||||
Reference in New Issue
Block a user