From a12dde333096adc5cbe792d318b7eeb6ad5b2dbb Mon Sep 17 00:00:00 2001 From: leegwae Date: Thu, 14 Sep 2023 19:38:54 +0900 Subject: [PATCH] =?UTF-8?q?refactor(question-mock):=20=EC=A7=88=EB=AC=B8?= =?UTF-8?q?=20id=20=EC=83=9D=EC=84=B1=ED=95=98=EB=8A=94=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=A0=95=EC=9D=98=ED=95=9C=EB=8B=A4=20(#413)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/data/question.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mocks/data/question.ts b/src/mocks/data/question.ts index 1198d98d..daff888b 100644 --- a/src/mocks/data/question.ts +++ b/src/mocks/data/question.ts @@ -2,9 +2,12 @@ import type { Question } from '@/lib/api/question'; import { faker } from '@faker-js/faker'; -let id = 0; +export const createMockQuestionId = (() => { + let id = 0; + return () => id++; +})(); export const createMockQuestion = (): Question => ({ - id: id++, + id: createMockQuestionId(), content: faker.lorem.sentences().slice(0, 200), answerNum: faker.datatype.number(5), likeNum: faker.datatype.number(10), @@ -12,7 +15,6 @@ export const createMockQuestion = (): Question => ({ createdAt: new Date().toString(), updatedAt: new Date().toString(), }); - export const createMockQuestionList = (size: number): Question[] => [...Array(size).keys()].map(createMockQuestion);