implement save of thread and members
This commit is contained in:
61
back/test/test-utils/test-attrsUtils.js
Normal file
61
back/test/test-utils/test-attrsUtils.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const { names } = require("./names");
|
||||
|
||||
function generateAttrs(options) {
|
||||
const attrs = {
|
||||
"size": 42,
|
||||
"envelope": {
|
||||
date: "2023-03-21T15:25:42.000Z",
|
||||
subject: options.subject ?? "subject" + randomString(10),
|
||||
from: options.from ?? null,
|
||||
sender: options.sender ?? null,
|
||||
replyTo: options.replyTo ?? null,
|
||||
to: options.to ?? null,
|
||||
cc: options.cc ?? null,
|
||||
bcc: options.bcc ?? null,
|
||||
inReplyTo: options.inReplyTo ?? null,
|
||||
messageId: options.messageId ?? randomString(10),
|
||||
},
|
||||
"date": options.date ?? new Date(),
|
||||
"flags": options.flags ?? [],
|
||||
"uid": options.uid ?? randomInt(3),
|
||||
"modseq": options.modseq ?? randomInt(7),
|
||||
"x-gm-labels": ["\\Inbox"],
|
||||
"x-gm-msgid": "1760991478422670209",
|
||||
"x-gm-thrid": "1760991478422670209",
|
||||
};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
function generateUsers(nb) {
|
||||
const users = [];
|
||||
for (let i = 0; i < nb; i++) {
|
||||
users.push({
|
||||
user: {
|
||||
name: "",
|
||||
mailbox: names[i],
|
||||
host: "provider.com",
|
||||
},
|
||||
id: i,
|
||||
});
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
function randomString(length) {
|
||||
let result = "";
|
||||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function randomInt(length) {
|
||||
return (Math.random() * Math.pow(10, length)).toFixed();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateAttrs,
|
||||
generateUsers,
|
||||
};
|
||||
Reference in New Issue
Block a user