Commit 6ed9bec4 authored by Ли Джен Сеп's avatar Ли Джен Сеп 💬

#5 удалил ненужные файлы и почистил код

parent 7b9451a2
POST http://localhost:8000/encode
POST http://localhost:8000/decode
{
"name": "homework83_m11",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MessageModule } from './message/message.module';
@Module({
imports: [MessageModule],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigModule } from '@nestjs/config'; import { ConfigModule } from '@nestjs/config';
import { MessageModule } from './message/message.module';
ConfigModule.forRoot(); ConfigModule.forRoot();
async function bootstrap() { async function startServer() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(MessageModule);
await app.listen(process.env.PORT ?? 3000); await app.listen(8000);
} }
bootstrap(); startServer();
import { PartialType } from '@nestjs/mapped-types';
import { CreateMessageDto } from './create-message.dto';
export class UpdateMessageDto extends PartialType(CreateMessageDto) {}
import { Test, TestingModule } from '@nestjs/testing';
import { MessageController } from './message.controller';
import { MessageService } from './message.service';
describe('MessageController', () => {
let controller: MessageController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [MessageController],
providers: [MessageService],
}).compile();
controller = module.get<MessageController>(MessageController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
import { Test, TestingModule } from '@nestjs/testing';
import { MessageService } from './message.service';
describe('MessageService', () => {
let service: MessageService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [MessageService],
}).compile();
service = module.get<MessageService>(MessageService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment