Skip to content

Commit

Permalink
[수정] eslint 오타 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeDragoN1123 committed Jan 1, 2024
1 parent 2018b0e commit cd87c91
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 45 deletions.
54 changes: 27 additions & 27 deletions src/events/events.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ mockPrisma = {
};
mockCacheManager = {
get: jest.fn(),
set: jest.fn()
}
set: jest.fn(),
};

mockCacheManager = {};
eventsService = new EventsService(mockCacheManager, mockPrisma);
Expand All @@ -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번 이벤트가 없습니다`);
}
})
});
});
13 changes: 11 additions & 2 deletions src/searches/searches.controller.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/searches/searches.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
27 changes: 12 additions & 15 deletions src/users/users.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('UsersController unit test', () => {
let controller: UsersController;
let service: UsersService;


const mockPrismaService = {
// 여기에 필요한 메서드를 mock 구현
};
Expand Down Expand Up @@ -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');
});
});

});

/*
Expand Down

0 comments on commit cd87c91

Please sign in to comment.