Skip to content

Commit

Permalink
docs: ✏️ change root=>sample
Browse files Browse the repository at this point in the history
  • Loading branch information
waynewyang committed Dec 29, 2023
1 parent 2484cf2 commit c0af5d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
********************************************************************************/

import { Module } from '@nestjs/common';
import { RootController } from './root/root.controller';
import { RootService } from './root/root.service';
import { SampleController } from './sample/sample.controller';
import { SampleService } from './sample/sample.service';
import { BackgroundTaskService } from './backgroundTask/provider/backgroundTask.service';

/**
* Root module for the application.
*/
@Module({
imports: [],
controllers: [RootController],
providers: [RootService, BackgroundTaskService],
controllers: [SampleController],
providers: [SampleService, BackgroundTaskService],
})
export class AppModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
********************************************************************************/

import { Controller, Get, Param } from '@nestjs/common';
import { RootService } from './root.service';
import { SampleService } from './sample.service';

/**
* Controller responsible for handling root-level requests.
*/
@Controller()
export class RootController {
export class SampleController {
/**
* Creates an instance of RootController.
* @param rootService - The RootService instance.
*/
constructor(private readonly rootService: RootService) {}
constructor(private readonly sampleService: SampleService) {}

/**
* Handles GET requests for root-level resources with an identifier.
Expand All @@ -40,6 +40,6 @@ export class RootController {
@Get(':id')
getHello(@Param() param): string {
console.log(param.id);
return this.rootService.getHello();
return this.sampleService.getHello();
}
}
2 changes: 1 addition & 1 deletion src/root/root.service.ts → src/sample/sample.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Injectable } from '@nestjs/common';
* Service responsible for providing root-level functionality.
*/
@Injectable()
export class RootService {
export class SampleService {
/**
* Gets a greeting message.
* @returns A string representing a greeting message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
********************************************************************************/

import { Test, TestingModule } from '@nestjs/testing';
import { RootController } from '../../src/root/root.controller';
import { RootService } from '../../src/root/root.service';
import { SampleController } from '../../src/sample/sample.controller';
import { SampleService } from '../../src/sample/sample.service';

describe('RootController', () => {
let rootController: RootController;
describe('SampleController', () => {
let sampleController: SampleController;

beforeEach(async () => {
const root: TestingModule = await Test.createTestingModule({
controllers: [RootController],
providers: [RootService],
controllers: [SampleController],
providers: [SampleService],
}).compile();

rootController = root.get<RootController>(RootController);
sampleController = root.get<SampleController>(SampleController);
});

describe('root', () => {
it('should return "Hello World!"', () => {
expect(rootController.getHello(1)).toBe('Hello World!');
expect(sampleController.getHello(1)).toBe('Hello World!');
});
});
});

0 comments on commit c0af5d8

Please sign in to comment.