parent
5eba301199
commit
12faf64595
@ -1,22 +0,0 @@ |
|||||||
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!'); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,12 +0,0 @@ |
|||||||
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(); |
|
||||||
} |
|
||||||
} |
|
@ -1,10 +1,10 @@ |
|||||||
import { Module } from '@nestjs/common'; |
import { Module } from '@nestjs/common'; |
||||||
import { AppController } from './app.controller'; |
import { HelloWorldController } from './hello-world/controller'; |
||||||
import { AppService } from './app.service'; |
import { HelloWorldService } from './hello-world/service'; |
||||||
|
|
||||||
@Module({ |
@Module({ |
||||||
imports: [], |
imports: [], |
||||||
controllers: [AppController], |
controllers: [HelloWorldController], |
||||||
providers: [AppService], |
providers: [HelloWorldService], |
||||||
}) |
}) |
||||||
export class AppModule {} |
export class AppModule {} |
||||||
|
@ -0,0 +1,22 @@ |
|||||||
|
import { Test, TestingModule } from '@nestjs/testing'; |
||||||
|
import { HelloWorldController } from './controller'; |
||||||
|
import { HelloWorldService } from './service'; |
||||||
|
|
||||||
|
describe('HelloWorldController', () => { |
||||||
|
let helloWorldController: HelloWorldController; |
||||||
|
|
||||||
|
beforeEach(async () => { |
||||||
|
const app: TestingModule = await Test.createTestingModule({ |
||||||
|
controllers: [HelloWorldController], |
||||||
|
providers: [HelloWorldService], |
||||||
|
}).compile(); |
||||||
|
|
||||||
|
helloWorldController = app.get<HelloWorldController>(HelloWorldController); |
||||||
|
}); |
||||||
|
|
||||||
|
describe('root', () => { |
||||||
|
it('should return "Hello World!"', () => { |
||||||
|
expect(helloWorldController.getHello()).toBe('Hello World!'); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,12 @@ |
|||||||
|
import { Controller, Get } from '@nestjs/common'; |
||||||
|
import { HelloWorldService } from './service'; |
||||||
|
|
||||||
|
@Controller('hello-world') |
||||||
|
export class HelloWorldController { |
||||||
|
constructor(private readonly helloWorldService: HelloWorldService) {} |
||||||
|
|
||||||
|
@Get() |
||||||
|
getHello(): string { |
||||||
|
return this.helloWorldService.getHello(); |
||||||
|
} |
||||||
|
} |
@ -1,7 +1,7 @@ |
|||||||
import { Injectable } from '@nestjs/common'; |
import { Injectable } from '@nestjs/common'; |
||||||
|
|
||||||
@Injectable() |
@Injectable() |
||||||
export class AppService { |
export class HelloWorldService { |
||||||
getHello(): string { |
getHello(): string { |
||||||
return 'Hello World!'; |
return 'Hello World!'; |
||||||
} |
} |
Loading…
Reference in new issue