diff --git a/src/events/events.service.spec.ts b/src/events/events.service.spec.ts index 7b35d27..fad8a00 100644 --- a/src/events/events.service.spec.ts +++ b/src/events/events.service.spec.ts @@ -16,8 +16,8 @@ mockPrisma = { }; mockCacheManager = { get: jest.fn(), - set: jest.fn() -} + set: jest.fn(), +}; mockCacheManager = {}; eventsService = new EventsService(mockCacheManager, mockPrisma); @@ -43,44 +43,44 @@ describe('EventsService', () => { category: '์‚ฐ์ฑ…', isDeleted: false, isVerified: '๐Ÿ™‹โ€โ™€๏ธ์•„๋ฌด๋‚˜', - eventImg: null + eventImg: null, }; - const createEventData = await eventsService.create(createEventDto) - expect(createEventData).toEqual(mockReturn) + const createEventData = await eventsService.create(createEventDto); + expect(createEventData).toEqual(mockReturn); expect(mockPrisma.event.creaet).toHaveBeenCalledWith({ - data: createEventDto - }) + data: createEventDto, + }); }); - test('findAll Method', async ()=> { - const mockReturn = 'findMany Value' - mockPrisma.event.findMany.mockReturnValue(mockReturn) + test('findAll Method', async () => { + const mockReturn = 'findMany Value'; + mockPrisma.event.findMany.mockReturnValue(mockReturn); - const page = 1 - const events = await eventsService.findAll(page) + const page = 1; + const events = await eventsService.findAll(page); - expect(events).toBe(mockReturn) - expect(eventsService.mockPrisma.event.findMany).toHaveBeenCalledTimes(1) - }) + expect(events).toBe(mockReturn); + expect(eventsService.mockPrisma.event.findMany).toHaveBeenCalledTimes(1); + }); - test('findOne Method', async ()=> { - const mockReturn = "findOne Value" - mockPrisma.event.findUnique.mockReturn(mockReturn) + test('findOne Method', async () => { + const mockReturn = 'findOne Value'; + mockPrisma.event.findUnique.mockReturn(mockReturn); - const result = await eventsService.findOne(1) - expect(result).toEqual(mockReturn) - }) + const result = await eventsService.findOne(1); + expect(result).toEqual(mockReturn); + }); - test('findOne NotFoundException', async ()=> { - mockPrisma.event.findUnique.mockReturnValue(null) + test('findOne NotFoundException', async () => { + mockPrisma.event.findUnique.mockReturnValue(null); try { - await eventsService.findOne(12345) + await eventsService.findOne(12345); } catch (err) { expect(eventsService.findOne).toHaveBeenCalledTimes(1); - expect(eventsService.findOne).toHaveBeenCalledWith(12345) + expect(eventsService.findOne).toHaveBeenCalledWith(12345); - expect(err.message).toEqual(`12345๋ฒˆ ์ด๋ฒคํŠธ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค`) + expect(err.message).toEqual(`12345๋ฒˆ ์ด๋ฒคํŠธ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค`); } - }) + }); }); diff --git a/src/searches/searches.controller.ts b/src/searches/searches.controller.ts index 41fbc0e..9c0c941 100644 --- a/src/searches/searches.controller.ts +++ b/src/searches/searches.controller.ts @@ -1,4 +1,10 @@ -import { Controller, Get, Injectable, ParseIntPipe, Query } from '@nestjs/common'; +import { + Controller, + Get, + Injectable, + ParseIntPipe, + Query, +} from '@nestjs/common'; import { SearchesService } from './searches.service'; import { ApiTags, ApiOperation } from '@nestjs/swagger'; import { SearchesDto } from './searches.dto/searches.dto'; @@ -11,7 +17,10 @@ export class SearchesController { @Get() @ApiOperation({ summary: 'ํ‚ค์›Œ๋“œ ๊ฒ€์ƒ‰, ์นดํ…Œ๊ณ ๋ฆฌ, ์ง€์—ญ, ์œ„์น˜์ธ์ฆ ํ•„ํ„ฐ๋ง' }) - async searchBy(@Query('page', ParseIntPipe) page:number, @Query() searchesDto: SearchesDto) { + async searchBy( + @Query('page', ParseIntPipe) page: number, + @Query() searchesDto: SearchesDto + ) { const events = await this.searchesService.search(page, searchesDto); const event = events.map((item) => { diff --git a/src/searches/searches.service.ts b/src/searches/searches.service.ts index 1b0dbd4..20c5abb 100644 --- a/src/searches/searches.service.ts +++ b/src/searches/searches.service.ts @@ -9,7 +9,7 @@ export class SearchesService { async search(page: number, searchesDto: SearchesDto) { return await this.prisma.event.findMany({ take: 4, - skip: page, + skip: page, where: { isDeleted: false, AND: [ diff --git a/src/users/users.controller.spec.ts b/src/users/users.controller.spec.ts index bf0b876..d7b3548 100644 --- a/src/users/users.controller.spec.ts +++ b/src/users/users.controller.spec.ts @@ -11,7 +11,6 @@ describe('UsersController unit test', () => { let controller: UsersController; let service: UsersService; - const mockPrismaService = { // ์—ฌ๊ธฐ์— ํ•„์š”ํ•œ ๋ฉ”์„œ๋“œ๋ฅผ mock ๊ตฌํ˜„ }; @@ -55,26 +54,24 @@ describe('UsersController unit test', () => { }); describe('Unit Tests', () => { - // 3. userId๋ฅผ ํ†ตํ•œ ์œ ์ € ์กฐํšŒ - // @Get(':id') - // @UseGuards(JwtAccessAuthGuard) // passport๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์ฆ ํ™•์ธ - // @ApiBearerAuth() // Swagger ๋ฌธ์„œ์— Bearer ํ† ํฐ ์ธ์ฆ ์ถ”๊ฐ€ - // @ApiOperation({ summary: 'ID๋กœ ํšŒ์› ์กฐํšŒ' }) - // @ApiResponse({ status: 200, description: '์œ ์ € ์ •๋ณด ์กฐํšŒ ์„ฑ๊ณต' }) - // async findOne(@Param('id') id: string) { - // const user = this.usersService.findOne(+id); - // if (!user) { - // throw new NotFoundException('User does not exist'); - // } - // return user; - // } + // @Get(':id') + // @UseGuards(JwtAccessAuthGuard) // passport๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์ฆ ํ™•์ธ + // @ApiBearerAuth() // Swagger ๋ฌธ์„œ์— Bearer ํ† ํฐ ์ธ์ฆ ์ถ”๊ฐ€ + // @ApiOperation({ summary: 'ID๋กœ ํšŒ์› ์กฐํšŒ' }) + // @ApiResponse({ status: 200, description: '์œ ์ € ์ •๋ณด ์กฐํšŒ ์„ฑ๊ณต' }) + // async findOne(@Param('id') id: string) { + // const user = this.usersService.findOne(+id); + // if (!user) { + // throw new NotFoundException('User does not exist'); + // } + // return user; + // } it('should return a status of 200', () => { controller.findOne('1'); expect(controller.findOne('1')).toBe('1'); }); }); - }); /*