46 lines
No EOL
1.1 KiB
TypeScript
46 lines
No EOL
1.1 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import { CacheFactory } from '../src/factories';
|
|
|
|
describe('DI Factories', () => {
|
|
describe('CacheFactory', () => {
|
|
it('should be exported', () => {
|
|
expect(CacheFactory).toBeDefined();
|
|
});
|
|
|
|
it('should create cache with configuration', () => {
|
|
const cacheConfig = {
|
|
redisConfig: {
|
|
host: 'localhost',
|
|
port: 6379,
|
|
db: 1,
|
|
},
|
|
keyPrefix: 'test:',
|
|
};
|
|
|
|
const cache = CacheFactory.create(cacheConfig);
|
|
expect(cache).toBeDefined();
|
|
});
|
|
|
|
it('should create null cache without config', () => {
|
|
const cache = CacheFactory.create();
|
|
expect(cache).toBeDefined();
|
|
expect(cache.type).toBe('null');
|
|
});
|
|
|
|
it('should create cache with logger', () => {
|
|
const mockLogger = {
|
|
info: () => {},
|
|
error: () => {},
|
|
warn: () => {},
|
|
debug: () => {},
|
|
};
|
|
|
|
const cacheConfig = {
|
|
logger: mockLogger,
|
|
};
|
|
|
|
const cache = CacheFactory.create(cacheConfig);
|
|
expect(cache).toBeDefined();
|
|
});
|
|
});
|
|
}) |