Sha256: 43ee1aa946ad791d32bb02fb132bc41c5d27353efc12fa1b3ddcb4858c5e8887
Contents?: true
Size: 1.15 KB
Versions: 48
Compression:
Stored size: 1.15 KB
Contents
import { date, image, lorem, name, random } from "faker/locale/en"; import { CommentFragment } from "../support/schema"; /** * Generate random comment data to emulate a database real content * @param {number} num - The number of comments to generate random data * @returns {Object[]} - An array of objects representing comments data */ const generateCommentsData = (num = 1) => { const commentsData: CommentFragment[] = []; for (let idx = 0; idx < num; idx += 1) { commentsData.push({ id: random.uuid(), type: "Decidim::Comments::Comment", body: lorem.words(), createdAt: date.past().toISOString(), author: { name: name.findName(), avatarUrl: image.imageUrl(), isVerified: Math.random() >= 0.5, isUser: Math.random() >= 0.5, deleted: false, }, hasComments: false, comments: [], acceptsNewComments: true, alignment: 0, upVotes: random.number(), upVoted: false, downVotes: random.number(), downVoted: false, sgid: random.uuid(), alreadyReported: false, }); } return commentsData; }; export default generateCommentsData;
Version data entries
48 entries across 48 versions & 2 rubygems