Sha256: 3406e1189a1c1e913c29414a90a1e8fa425fb32af8e2ab1bd676bd60b3312995
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 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(), }, 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
4 entries across 4 versions & 2 rubygems