Sha256: 48614636ab596cf681bad381c10483255ea70cc92292da9045b2cb58610ac104
Contents?: true
Size: 1.41 KB
Versions: 16
Compression:
Stored size: 1.41 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) { const creationDate = date.recent(); const nickname = name.findName(); commentsData.push({ id: random.uuid(), type: "Decidim::Comments::Comment", body: lorem.words(), formattedBody: lorem.words(), createdAt: creationDate.toISOString(), formattedCreatedAt: creationDate.toLocaleTimeString(), author: { name: `${name.firstName()} ${name.lastName()}`, nickname: `@${nickname}`, avatarUrl: image.imageUrl(), profilePath: `/profiles/${nickname}`, deleted: false, badge: "verified-badge" }, hasComments: false, comments: [], acceptsNewComments: true, userAllowedToComment: 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
16 entries across 16 versions & 1 rubygems