advancements in tests and storing messages
This commit is contained in:
52
back/test/mail/saveMessage-test.js
Normal file
52
back/test/mail/saveMessage-test.js
Normal file
@@ -0,0 +1,52 @@
|
||||
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);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user