refactor
This commit is contained in:
@@ -12,24 +12,14 @@ describe('AnalyticsController', () => {
|
||||
let controller: AnalyticsController;
|
||||
let service: ReturnType<typeof vi.mocked<AnalyticsService>>;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AnalyticsController],
|
||||
providers: [
|
||||
{
|
||||
provide: AnalyticsService,
|
||||
useValue: {
|
||||
recordPageView: vi.fn(),
|
||||
recordEngagement: vi.fn(),
|
||||
getDashboardData: vi.fn(),
|
||||
getAnalyticsMetrics: vi.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<AnalyticsController>(AnalyticsController);
|
||||
service = vi.mocked(module.get(AnalyticsService));
|
||||
beforeEach(() => {
|
||||
service = {
|
||||
recordPageView: vi.fn(),
|
||||
recordEngagement: vi.fn(),
|
||||
getDashboardData: vi.fn(),
|
||||
getAnalyticsMetrics: vi.fn(),
|
||||
} as any;
|
||||
controller = new AnalyticsController(service);
|
||||
});
|
||||
|
||||
describe('recordPageView', () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AnalyticsModule } from './AnalyticsModule';
|
||||
import { AnalyticsController } from './AnalyticsController';
|
||||
import { AnalyticsService } from './AnalyticsService';
|
||||
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
|
||||
|
||||
describe('AnalyticsModule', () => {
|
||||
let module: TestingModule;
|
||||
@@ -9,7 +10,10 @@ describe('AnalyticsModule', () => {
|
||||
beforeEach(async () => {
|
||||
module = await Test.createTestingModule({
|
||||
imports: [AnalyticsModule],
|
||||
}).compile();
|
||||
})
|
||||
.overrideProvider('Logger_TOKEN')
|
||||
.useClass(ConsoleLogger)
|
||||
.compile();
|
||||
});
|
||||
|
||||
it('should compile the module', () => {
|
||||
|
||||
Reference in New Issue
Block a user