Skip to content

Commit

Permalink
[#1] add testfile for testing automation
Browse files Browse the repository at this point in the history
  • Loading branch information
le2sky committed Feb 25, 2022
1 parent 66fc9de commit 3565b54
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';

describe('AppController', () => {
let controller: AppController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AppController],
}).compile();

controller = module.get<AppController>(AppController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
9 changes: 9 additions & 0 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Controller, Get } from '@nestjs/common';

@Controller()
export class AppController {
@Get()
sayHi() {
return 'hi';
}
}
4 changes: 4 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { validationSchema } from './config/validationSchema';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [
Expand All @@ -26,5 +28,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
}),
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
18 changes: 18 additions & 0 deletions src/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppService } from './app.service';

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

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AppService],
}).compile();

service = module.get<AppService>(AppService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
4 changes: 4 additions & 0 deletions src/app.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {}

0 comments on commit 3565b54

Please sign in to comment.