import { Test, TestingModule } from '@nestjs/testing';
import { QuizService } from './quiz.service';
import {getModelToken} from "@nestjs/mongoose";
import {Question} from "../schemas/question.schema";
import {Model} from "mongoose";
import {QuestionStorage} from "../schemas/question-storage.schema";
import {GuestsService} from "../guests/guests.service";
import {GuestsServiceMock} from "../mocks/guests-service.mock";
import {SharedService} from "../shared/shared.service";
import {SharedServiceMock} from "../mocks/shared-service.mock";
import {CommandBus, EventBus} from "@nestjs/cqrs";
import {EventbusMock} from "../mocks/eventbus.mock";
import {CommandbusMock} from "../mocks/commandbus.mock";
import {FeatureflagService} from "../featureflag/featureflag.service";
import {FeatureflagServiceMock} from "../mocks/featureflag-service.mock";

describe('QuizService', () => {
  let service: QuizService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        QuizService,
        { provide: getModelToken(Question.name), useValue: Model },
        { provide: getModelToken(QuestionStorage.name), useValue: Model},
        { provide: GuestsService, useValue: GuestsServiceMock },
        { provide: SharedService, useValue: SharedServiceMock },
        { provide: EventBus, useValue: EventbusMock },
        { provide: CommandBus, useValue: CommandbusMock },
        { provide: FeatureflagService, useValue: FeatureflagServiceMock }
      ],
    }).compile();

    service = await module.resolve<QuizService>(QuizService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
