Skip to content

Commit

Permalink
refactor(question-mock): 질문 id 생성하는 함수 정의한다 (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
leegwae committed Sep 17, 2023
1 parent f357016 commit 7486f2f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mocks/data/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ 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),
authorId: '익명 사용자 토큰',
createdAt: new Date().toString(),
updatedAt: new Date().toString(),
});

export const createMockQuestionList = (size: number): Question[] =>
[...Array(size).keys()].map(createMockQuestion);

Expand Down

0 comments on commit 7486f2f

Please sign in to comment.