mail/back/test/mail/saveMessage-test.js
2023-03-25 16:47:23 +01:00

53 lines
1.5 KiB
JavaScript

process.env["NODE_DEV"] = "TEST";
const { saveFromParsedData } = require("../../mails/storeMessage");
const { TestDb } = require("../sql/test-utilsDb");
const MYSQL = require("../../db/config.json").MYSQL;
let db;
beforeAll(async () => {
const options = {
databaseOptions: {
host: "localhost",
port: 3306,
user: MYSQL.user,
password: MYSQL.pwd,
database: "mail_test",
},
dbSchema: "../../sql/structureV2.sql",
};
db = new TestDb(options);
await db.init();
});
afterAll(async () => {
db.cleanTables();
});
describe("saveMessage", async () => {
describe("rooms", async () => {
it("messages not related and from same sender should be in the same room", async () => {
await saveFromParsedData(
{
to: { value: [{ address: "address1@email.com" }] },
from: { value: [{ address: "address2@email.com" }] },
messageId: "<messageId1>",
},
1,
);
await saveFromParsedData(
{
to: { value: [{ address: "address1@email.com" }] },
from: { value: [{ address: "address2@email.com" }] },
messageId: "<messageId2>",
},
2,
);
// todo call parser
const query = ""
db.execQueryAsync().then((res) => {
expect(res.length).toBe(2);
})
});
});
});