Skip to content

Commit

Permalink
refactor(#204): mocking 시에 findLotusDetail을 repository에서 controller로 …
Browse files Browse the repository at this point in the history
…변경하기
  • Loading branch information
naarang committed Dec 5, 2024
1 parent baebb61 commit 2c4e4bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apps/frontend/src/app/mock/controller/lotusController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultBodyType, HttpResponse, PathParams, StrictRequest } from 'msw';
import { lotusRepository } from '@/app/mock/repository/lotusRepository';
import { lotusMockFileData, lotusRepository } from '@/app/mock/repository/lotusRepository';
import { userRepository } from '@/app/mock/repository/userRepository';
import { LotusDto } from '@/feature/lotus';

Expand Down Expand Up @@ -61,9 +61,9 @@ export const getPublicLotusList = async ({ request }: { request: StrictRequest<D
export const getLotusDetail = async ({ params }: { params: Record<string, string> }) => {
const lotusId = params.lotusId;

const lotus = await lotusRepository.findLotusDetail({ id: lotusId });
const lotus = await lotusRepository.findOne({ id: lotusId });

return HttpResponse.json(lotus);
return HttpResponse.json({ ...lotus, ...lotusMockFileData });
};

type CreateLotusDto = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './lotusRepository';
export * from './lotusMockData';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lotusMockData, lotusMockFileData } from './lotusMockData';
import { lotusMockData } from './lotusMockData';
import { MockRepository } from '@/app/mock/MockRepository';
import { LotusDto } from '@/feature/lotus';
import { UserDto } from '@/feature/user';
Expand All @@ -22,12 +22,6 @@ class LotusRepository extends MockRepository<Omit<LotusDto & { author: UserDto }

return this.paginate(filtered, page, size);
}

async findLotusDetail(query: Partial<LotusDto>) {
const lotus = await lotusRepository.findOne(query);

return { ...lotus, ...lotusMockFileData };
}
}

export const lotusRepository = new LotusRepository();
Expand Down

0 comments on commit 2c4e4bb

Please sign in to comment.