Removed example hello world endpoint

This commit is contained in:
Thom Werring 2023-10-26 22:07:17 +02:00
parent e6ebb0e4c1
commit 8cd335dac7
5 changed files with 4 additions and 39 deletions

View file

@ -1,6 +1,5 @@
import { Test, TestingModule } from "@nestjs/testing"; import { Test, TestingModule } from "@nestjs/testing";
import { AppController } from "@/app.controller"; import { AppController } from "@/app.controller";
import { AppService } from "@/app.service";
import { SkillsService } from "@/skills/skills.service"; import { SkillsService } from "@/skills/skills.service";
import { ExperiencesService } from "@/experiences/experiences.service"; import { ExperiencesService } from "@/experiences/experiences.service";
import { SkillDto } from "@/skills/skills.types"; import { SkillDto } from "@/skills/skills.types";
@ -12,7 +11,6 @@ import { IntroDto } from "@/intro/intro.types";
describe("AppController", () => { describe("AppController", () => {
let appController: AppController; let appController: AppController;
let appService: AppService;
let skillsService: SkillsService; let skillsService: SkillsService;
let experiencesService: ExperiencesService; let experiencesService: ExperiencesService;
let educationService: EducationService; let educationService: EducationService;
@ -21,29 +19,16 @@ describe("AppController", () => {
beforeEach(async () => { beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({ const app: TestingModule = await Test.createTestingModule({
controllers: [AppController], controllers: [AppController],
providers: [AppService, SkillsService, ExperiencesService, EducationService, IntroService], providers: [SkillsService, ExperiencesService, EducationService, IntroService],
}).compile(); }).compile();
appController = app.get<AppController>(AppController); appController = app.get<AppController>(AppController);
appService = app.get<AppService>(AppService);
skillsService = app.get<SkillsService>(SkillsService); skillsService = app.get<SkillsService>(SkillsService);
experiencesService = app.get<ExperiencesService>(ExperiencesService); experiencesService = app.get<ExperiencesService>(ExperiencesService);
educationService = app.get<EducationService>(EducationService); educationService = app.get<EducationService>(EducationService);
introService = app.get<IntroService>(IntroService); introService = app.get<IntroService>(IntroService);
}); });
describe("root", () => {
it("Should call AppService", () => {
jest.spyOn(appService, "sayHello").mockImplementation(() => "Hello World!");
appController.sayHello();
expect(appService.sayHello).toBeCalled();
});
it('should return "Hello World!"', () => {
expect(appController.sayHello()).toBe("Hello World!");
});
});
describe("getSkills", () => { describe("getSkills", () => {
it("Should return an Array of SkillDtos", () => { it("Should return an Array of SkillDtos", () => {
const result: SkillDto[] = SkillDto.asDto([ const result: SkillDto[] = SkillDto.asDto([

View file

@ -1,6 +1,5 @@
import { Controller, Get } from "@nestjs/common"; import { Controller, Get } from "@nestjs/common";
import { AppService } from "@/app.service"; import { ApiExtraModels, ApiOkResponse, ApiTags, getSchemaPath } from "@nestjs/swagger";
import { ApiExcludeEndpoint, ApiExtraModels, ApiOkResponse, ApiTags, getSchemaPath } from "@nestjs/swagger";
import { SkillsService } from "@/skills/skills.service"; import { SkillsService } from "@/skills/skills.service";
import { ExperiencesService } from "@/experiences/experiences.service"; import { ExperiencesService } from "@/experiences/experiences.service";
import { SkillDto } from "@/skills/skills.types"; import { SkillDto } from "@/skills/skills.types";
@ -14,19 +13,12 @@ import { IntroService } from "@/intro/intro.service";
@ApiExtraModels(SkillDto, ExperienceDto, EducationDto, IntroDto) @ApiExtraModels(SkillDto, ExperienceDto, EducationDto, IntroDto)
export class AppController { export class AppController {
constructor( constructor(
private readonly appService: AppService,
private readonly skillsService: SkillsService, private readonly skillsService: SkillsService,
private readonly experiencesService: ExperiencesService, private readonly experiencesService: ExperiencesService,
private readonly educationService: EducationService, private readonly educationService: EducationService,
private readonly introService: IntroService private readonly introService: IntroService
) {} ) {}
@Get()
@ApiExcludeEndpoint()
sayHello(): string {
return this.appService.sayHello();
}
@Get("skills") @Get("skills")
@ApiTags("Skills") @ApiTags("Skills")
@ApiOkResponse({ @ApiOkResponse({

View file

@ -1,6 +1,5 @@
import { Module } from "@nestjs/common"; import { Module } from "@nestjs/common";
import { AppController } from "@/app.controller"; import { AppController } from "@/app.controller";
import { AppService } from "@/app.service";
import { SkillsService } from "@/skills/skills.service"; import { SkillsService } from "@/skills/skills.service";
import { ExperiencesService } from "@/experiences/experiences.service"; import { ExperiencesService } from "@/experiences/experiences.service";
import { EducationService } from "@/education/education.service"; import { EducationService } from "@/education/education.service";
@ -9,6 +8,6 @@ import { IntroService } from "@/intro/intro.service";
@Module({ @Module({
imports: [], imports: [],
controllers: [AppController], controllers: [AppController],
providers: [AppService, SkillsService, ExperiencesService, EducationService, IntroService], providers: [SkillsService, ExperiencesService, EducationService, IntroService],
}) })
export class AppModule {} export class AppModule {}

View file

@ -1,8 +0,0 @@
import { Injectable } from "@nestjs/common";
@Injectable()
export class AppService {
sayHello(): string {
return "Hello World!";
}
}

View file

@ -1,7 +1,7 @@
import { Test, TestingModule } from "@nestjs/testing"; import { Test, TestingModule } from "@nestjs/testing";
import { INestApplication } from "@nestjs/common"; import { INestApplication } from "@nestjs/common";
import * as request from "supertest"; import * as request from "supertest";
import { AppModule } from "./../src/app.module"; import { AppModule } from "@/app.module";
describe("AppController (e2e)", () => { describe("AppController (e2e)", () => {
let app: INestApplication; let app: INestApplication;
@ -15,7 +15,4 @@ describe("AppController (e2e)", () => {
await app.init(); await app.init();
}); });
it("/ (GET)", () => {
return request(app.getHttpServer()).get("/").expect(200).expect("Hello World!");
});
}); });