TGD-31: fix all tests suites
This commit is contained in:
parent
0a4176aa93
commit
9e4f5e13c0
29 changed files with 207 additions and 12 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { CardsController } from './cards.controller';
|
import { CardsController } from './cards.controller';
|
||||||
|
import {CardsService} from "./cards.service";
|
||||||
|
import {CardsServiceMock} from "../mocks/cards-service.mock";
|
||||||
|
|
||||||
describe('CardsController', () => {
|
describe('CardsController', () => {
|
||||||
let controller: CardsController;
|
let controller: CardsController;
|
||||||
|
|
@ -7,6 +9,9 @@ describe('CardsController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [CardsController],
|
controllers: [CardsController],
|
||||||
|
providers: [
|
||||||
|
{ provide: CardsService, useValue: CardsServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<CardsController>(CardsController);
|
controller = module.get<CardsController>(CardsController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,24 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { CardsService } from './cards.service';
|
import { CardsService } from './cards.service';
|
||||||
|
import {ConfigService} from "@nestjs/config";
|
||||||
|
import {ConfigServiceMock} from "../mocks/config-service.mock";
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {Card} from "../schemas/cards.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
import {EventBus} from "@nestjs/cqrs";
|
||||||
|
import {EventbusMock} from "../mocks/eventbus.mock";
|
||||||
|
|
||||||
describe('CardsService', () => {
|
describe('CardsService', () => {
|
||||||
let service: CardsService;
|
let service: CardsService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [CardsService],
|
providers: [
|
||||||
|
CardsService,
|
||||||
|
{ provide: ConfigService, useValue: ConfigServiceMock },
|
||||||
|
{ provide: getModelToken(Card.name), useValue: Model },
|
||||||
|
{ provide: EventBus, useValue: EventbusMock },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<CardsService>(CardsService);
|
service = module.get<CardsService>(CardsService);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GameController } from './game.controller';
|
import { GameController } from './game.controller';
|
||||||
|
import {GameService} from "./game.service";
|
||||||
|
import {GameServiceMock} from "../mocks/game-service.mock";
|
||||||
|
|
||||||
describe('GameController', () => {
|
describe('GameController', () => {
|
||||||
let controller: GameController;
|
let controller: GameController;
|
||||||
|
|
@ -7,6 +9,9 @@ describe('GameController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [GameController],
|
controllers: [GameController],
|
||||||
|
providers: [
|
||||||
|
{ provide: GameService, useValue: GameServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<GameController>(GameController);
|
controller = module.get<GameController>(GameController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,31 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GameService } from './game.service';
|
import { GameService } from './game.service';
|
||||||
|
import {CommandBus, EventBus, QueryBus} from "@nestjs/cqrs";
|
||||||
|
import {CommandbusMock} from "../mocks/commandbus.mock";
|
||||||
|
import {EventbusMock} from "../mocks/eventbus.mock";
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {GameQueue} from "../schemas/game-queue.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
import {ConfigService} from "@nestjs/config";
|
||||||
|
import {ConfigServiceMock} from "../mocks/config-service.mock";
|
||||||
|
import {SharedService} from "../shared/shared.service";
|
||||||
|
import {SharedServiceMock} from "../mocks/shared-service.mock";
|
||||||
|
import {QueryBusMock} from "../mocks/querybus.mock";
|
||||||
|
|
||||||
describe('GameService', () => {
|
describe('GameService', () => {
|
||||||
let service: GameService;
|
let service: GameService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [GameService],
|
providers: [
|
||||||
|
GameService,
|
||||||
|
{ provide: CommandBus, useValue: CommandbusMock },
|
||||||
|
{ provide: EventBus, useValue: EventbusMock },
|
||||||
|
{ provide: getModelToken(GameQueue.name), useValue: Model },
|
||||||
|
{ provide: ConfigService, useValue: ConfigServiceMock },
|
||||||
|
{ provide: SharedService, useValue: SharedServiceMock },
|
||||||
|
{ provide: QueryBus, useValue: QueryBusMock },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<GameService>(GameService);
|
service = module.get<GameService>(GameService);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GiftsController } from './gifts.controller';
|
import { GiftsController } from './gifts.controller';
|
||||||
|
import {GiftsService} from "./gifts.service";
|
||||||
|
import {GiftServiceMock} from "../mocks/gift-service.mock";
|
||||||
|
|
||||||
describe('GiftsController', () => {
|
describe('GiftsController', () => {
|
||||||
let controller: GiftsController;
|
let controller: GiftsController;
|
||||||
|
|
@ -7,6 +9,9 @@ describe('GiftsController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [GiftsController],
|
controllers: [GiftsController],
|
||||||
|
providers: [
|
||||||
|
{ provide: GiftsService, useValue: GiftServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<GiftsController>(GiftsController);
|
controller = module.get<GiftsController>(GiftsController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GiftsService } from './gifts.service';
|
import { GiftsService } from './gifts.service';
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {Prize} from "../schemas/prize.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
|
||||||
describe('GiftsService', () => {
|
describe('GiftsService', () => {
|
||||||
let service: GiftsService;
|
let service: GiftsService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [GiftsService],
|
providers: [
|
||||||
|
GiftsService,
|
||||||
|
{ provide: getModelToken(Prize.name), useValue: Model },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<GiftsService>(GiftsService);
|
service = module.get<GiftsService>(GiftsService);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GuestsController } from './guests.controller';
|
import { GuestsController } from './guests.controller';
|
||||||
|
import {GuestsService} from "./guests.service";
|
||||||
|
import {GuestsServiceMock} from "../mocks/guests-service.mock";
|
||||||
|
|
||||||
describe('GuestsController', () => {
|
describe('GuestsController', () => {
|
||||||
let controller: GuestsController;
|
let controller: GuestsController;
|
||||||
|
|
@ -7,6 +9,9 @@ describe('GuestsController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [GuestsController],
|
controllers: [GuestsController],
|
||||||
|
providers: [
|
||||||
|
{ provide: GuestsService, useValue: GuestsServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<GuestsController>(GuestsController);
|
controller = module.get<GuestsController>(GuestsController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,39 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GuestsService } from './guests.service';
|
import { GuestsService } from './guests.service';
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {Guest} from "../schemas/guest.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
import {Config} from "../schemas/config.schema";
|
||||||
|
import {ClientProxy} from "@nestjs/microservices";
|
||||||
|
import {ClientProxyMock} from "../mocks/client-proxy.mock";
|
||||||
|
import {CommandBus, EventBus, QueryBus} from "@nestjs/cqrs";
|
||||||
|
import {EventbusMock} from "../mocks/eventbus.mock";
|
||||||
|
import {CommandbusMock} from "../mocks/commandbus.mock";
|
||||||
|
import {CardsServiceMock} from "../mocks/cards-service.mock";
|
||||||
|
import {CardsService} from "../cards/cards.service";
|
||||||
|
import {ConfigService} from "@nestjs/config";
|
||||||
|
import {ConfigServiceMock} from "../mocks/config-service.mock";
|
||||||
|
import {QueryBusMock} from "../mocks/querybus.mock";
|
||||||
|
import {VoiceService} from "../voice/voice.service";
|
||||||
|
import {VoiceServiceMock} from "../mocks/voice-service.mock";
|
||||||
|
|
||||||
describe('GuestsService', () => {
|
describe('GuestsService', () => {
|
||||||
let service: GuestsService;
|
let service: GuestsService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [GuestsService],
|
providers: [
|
||||||
|
GuestsService,
|
||||||
|
{ provide: getModelToken(Guest.name), useValue: Model },
|
||||||
|
{ provide: getModelToken(Config.name), useValue: Model },
|
||||||
|
{ provide: 'Telegram', useValue: ClientProxyMock },
|
||||||
|
{ provide: EventBus, useValue: EventbusMock },
|
||||||
|
{ provide: CommandBus, useValue: CommandbusMock },
|
||||||
|
{ provide: CardsService, useValue: CardsServiceMock },
|
||||||
|
{ provide: ConfigService, useValue: ConfigServiceMock },
|
||||||
|
{ provide: QueryBus, useValue: QueryBusMock },
|
||||||
|
{ provide: VoiceService, useValue: VoiceServiceMock },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<GuestsService>(GuestsService);
|
service = module.get<GuestsService>(GuestsService);
|
||||||
|
|
|
||||||
3
src/mocks/cards-service.mock.ts
Normal file
3
src/mocks/cards-service.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const CardsServiceMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/client-proxy.mock.ts
Normal file
3
src/mocks/client-proxy.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const ClientProxyMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/commandbus.mock.ts
Normal file
3
src/mocks/commandbus.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const CommandbusMock = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
export const ConfigServiceMock = {
|
export const ConfigServiceMock = {
|
||||||
|
get: jest.fn(),
|
||||||
}
|
}
|
||||||
3
src/mocks/eventbus.mock.ts
Normal file
3
src/mocks/eventbus.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const EventbusMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/game-service.mock.ts
Normal file
3
src/mocks/game-service.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const GameServiceMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/guests-service.mock.ts
Normal file
3
src/mocks/guests-service.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const GuestsServiceMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/httpservice.mock.ts
Normal file
3
src/mocks/httpservice.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const HttpServiceMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/penalty-service.mock.ts
Normal file
3
src/mocks/penalty-service.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const PenaltyServiceMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/querybus.mock.ts
Normal file
3
src/mocks/querybus.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const QueryBusMock = {
|
||||||
|
|
||||||
|
}
|
||||||
3
src/mocks/socket-gateway.mock.ts
Normal file
3
src/mocks/socket-gateway.mock.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const SocketGatewayMock = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { PenaltyController } from './penalty.controller';
|
import { PenaltyController } from './penalty.controller';
|
||||||
|
import {PenaltyService} from "./penalty.service";
|
||||||
|
import {PenaltyServiceMock} from "../mocks/penalty-service.mock";
|
||||||
|
|
||||||
describe('PenaltyController', () => {
|
describe('PenaltyController', () => {
|
||||||
let controller: PenaltyController;
|
let controller: PenaltyController;
|
||||||
|
|
@ -7,6 +9,9 @@ describe('PenaltyController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [PenaltyController],
|
controllers: [PenaltyController],
|
||||||
|
providers: [
|
||||||
|
{ provide: PenaltyService, useValue: PenaltyServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<PenaltyController>(PenaltyController);
|
controller = module.get<PenaltyController>(PenaltyController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { PenaltyService } from './penalty.service';
|
import { PenaltyService } from './penalty.service';
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {Penalty} from "../schemas/penalty.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
|
||||||
describe('PenaltyService', () => {
|
describe('PenaltyService', () => {
|
||||||
let service: PenaltyService;
|
let service: PenaltyService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [PenaltyService],
|
providers: [
|
||||||
|
PenaltyService,
|
||||||
|
{ provide: getModelToken(Penalty.name), useValue: Model },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<PenaltyService>(PenaltyService);
|
service = module.get<PenaltyService>(PenaltyService);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,22 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { QuizController } from './quiz.controller';
|
import { QuizController } from './quiz.controller';
|
||||||
|
import {QuizService} from "./quiz.service";
|
||||||
|
import {QuizServiceMock} from "../mocks/quiz-service.mock";
|
||||||
|
|
||||||
describe('QuizController', () => {
|
describe('QuizController', () => {
|
||||||
let controller: QuizController;
|
let controller: QuizController;
|
||||||
|
let quizService: QuizService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [QuizController],
|
controllers: [QuizController],
|
||||||
|
providers: [
|
||||||
|
{ provide: QuizService, useValue: QuizServiceMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<QuizController>(QuizController);
|
controller = module.get<QuizController>(QuizController);
|
||||||
|
quizService = module.get<QuizService>(QuizService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,34 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { QuizService } from './quiz.service';
|
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";
|
||||||
|
|
||||||
describe('QuizService', () => {
|
describe('QuizService', () => {
|
||||||
let service: QuizService;
|
let service: QuizService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [QuizService],
|
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 }
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<QuizService>(QuizService);
|
service = await module.resolve<QuizService>(QuizService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import {QuizService} from "../quiz/quiz.service";
|
||||||
import {QuizServiceMock} from "../mocks/quiz-service.mock";
|
import {QuizServiceMock} from "../mocks/quiz-service.mock";
|
||||||
import {SharedService} from "../shared/shared.service";
|
import {SharedService} from "../shared/shared.service";
|
||||||
import {SharedServiceMock} from "../mocks/shared-service.mock";
|
import {SharedServiceMock} from "../mocks/shared-service.mock";
|
||||||
|
import {FeatureflagService} from "../featureflag/featureflag.service";
|
||||||
|
import {FeatureflagServiceMock} from "../mocks/featureflag-service.mock";
|
||||||
|
|
||||||
|
|
||||||
describe('SchedulerService', () => {
|
describe('SchedulerService', () => {
|
||||||
|
|
@ -15,6 +17,7 @@ describe('SchedulerService', () => {
|
||||||
let giftService: GiftsService;
|
let giftService: GiftsService;
|
||||||
let sharedService: SharedService;
|
let sharedService: SharedService;
|
||||||
let stateService: StateService;
|
let stateService: StateService;
|
||||||
|
let featureFlagService: FeatureflagService;
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
|
@ -23,6 +26,7 @@ describe('SchedulerService', () => {
|
||||||
{ provide: StateService, useValue: StateServiceMock },
|
{ provide: StateService, useValue: StateServiceMock },
|
||||||
{ provide: QuizService, useValue: QuizServiceMock },
|
{ provide: QuizService, useValue: QuizServiceMock },
|
||||||
{ provide: SharedService, useValue: SharedServiceMock },
|
{ provide: SharedService, useValue: SharedServiceMock },
|
||||||
|
{ provide: FeatureflagService, useValue: FeatureflagServiceMock }
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
|
|
@ -30,6 +34,7 @@ describe('SchedulerService', () => {
|
||||||
giftService = module.get<GiftsService>(GiftsService);
|
giftService = module.get<GiftsService>(GiftsService);
|
||||||
sharedService = module.get<SharedService>(SharedService);
|
sharedService = module.get<SharedService>(SharedService);
|
||||||
stateService = module.get<StateService>(StateService);
|
stateService = module.get<StateService>(StateService);
|
||||||
|
featureFlagService = module.get<FeatureflagService>(FeatureflagService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,21 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { SharedService } from './shared.service';
|
import { SharedService } from './shared.service';
|
||||||
|
import {SocketGateway} from "../socket/socket.gateway";
|
||||||
|
import {SocketGatewayMock} from "../mocks/socket-gateway.mock";
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {Config} from "../schemas/config.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
|
||||||
describe('SharedService', () => {
|
describe('SharedService', () => {
|
||||||
let service: SharedService;
|
let service: SharedService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [SharedService],
|
providers: [
|
||||||
|
SharedService,
|
||||||
|
{ provide: SocketGateway, useValue: SocketGatewayMock },
|
||||||
|
{ provide: getModelToken(Config.name), useValue: Model },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<SharedService>(SharedService);
|
service = module.get<SharedService>(SharedService);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ export class SharedService {
|
||||||
private logger = new Logger(SharedService.name);
|
private logger = new Logger(SharedService.name);
|
||||||
constructor(
|
constructor(
|
||||||
private socketGateway: SocketGateway,
|
private socketGateway: SocketGateway,
|
||||||
private eventBus: EventBus,
|
|
||||||
@InjectModel(Config.name)
|
@InjectModel(Config.name)
|
||||||
private configModel: Model<ConfigDocument>,
|
private configModel: Model<ConfigDocument>,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { StateController } from './state.controller';
|
import { StateController } from './state.controller';
|
||||||
|
import {State} from "../schemas/state.schema";
|
||||||
|
import {StateService} from "./state.service";
|
||||||
|
import {StateServiceMock} from "../mocks/state-service.mock";
|
||||||
|
import {SharedService} from "../shared/shared.service";
|
||||||
|
import {SharedServiceMock} from "../mocks/shared-service.mock";
|
||||||
|
import {EventBus} from "@nestjs/cqrs";
|
||||||
|
import {EventbusMock} from "../mocks/eventbus.mock";
|
||||||
|
import {ClientProxyMock} from "../mocks/client-proxy.mock";
|
||||||
|
|
||||||
describe('StateController', () => {
|
describe('StateController', () => {
|
||||||
let controller: StateController;
|
let controller: StateController;
|
||||||
|
|
@ -7,6 +15,12 @@ describe('StateController', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [StateController],
|
controllers: [StateController],
|
||||||
|
providers: [
|
||||||
|
{ provide: StateService, useValue: StateServiceMock },
|
||||||
|
{ provide: SharedService, useValue: SharedServiceMock },
|
||||||
|
{ provide: EventBus, useValue: EventbusMock },
|
||||||
|
{ provide: 'Telegram', useValue: ClientProxyMock },
|
||||||
|
]
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<StateController>(StateController);
|
controller = module.get<StateController>(StateController);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,21 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { StateService } from './state.service';
|
import { StateService } from './state.service';
|
||||||
|
import {getModelToken} from "@nestjs/mongoose";
|
||||||
|
import {State} from "../schemas/state.schema";
|
||||||
|
import {Model} from "mongoose";
|
||||||
|
import {EventBus} from "@nestjs/cqrs";
|
||||||
|
import {EventbusMock} from "../mocks/eventbus.mock";
|
||||||
|
|
||||||
describe('StateService', () => {
|
describe('StateService', () => {
|
||||||
let service: StateService;
|
let service: StateService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [StateService],
|
providers: [
|
||||||
|
StateService,
|
||||||
|
{ provide: getModelToken(State.name), useValue: Model },
|
||||||
|
{ provide: EventBus, useValue: EventbusMock },
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<StateService>(StateService);
|
service = module.get<StateService>(StateService);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { VoiceService } from './voice.service';
|
import { VoiceService } from './voice.service';
|
||||||
|
import {HttpService} from "@nestjs/axios";
|
||||||
|
import {HttpServiceMock} from "../mocks/httpservice.mock";
|
||||||
|
import {ConfigService} from "@nestjs/config";
|
||||||
|
import {ConfigServiceMock} from "../mocks/config-service.mock";
|
||||||
|
|
||||||
describe('VoiceService', () => {
|
describe('VoiceService', () => {
|
||||||
let service: VoiceService;
|
let service: VoiceService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [VoiceService],
|
providers: [
|
||||||
|
VoiceService,
|
||||||
|
{ provide: HttpService, useValue: HttpServiceMock },
|
||||||
|
{ provide: ConfigService, useValue: ConfigServiceMock }
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<VoiceService>(VoiceService);
|
service = module.get<VoiceService>(VoiceService);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue