trying stuff to mock mysql
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
import mysql from "mysql";
|
||||
|
||||
jest.mock("mysql");
|
||||
mysql.createConnection = jest.fn();
|
||||
mysql.createConnection.mockImplementation(() => {
|
||||
return { connect: () => new Promise((resolve, rejects) => resolve(true)) };
|
||||
});
|
||||
|
||||
import { generateAttrs, generateUsers } from "../test-utils/test-attrsUtils";
|
||||
import registerMessageInApp, { roomType } from "../../mails/saveMessage";
|
||||
import { jest, describe, it, expect } from "@jest/globals";
|
||||
@@ -5,7 +13,6 @@ import { jest, describe, it, expect } from "@jest/globals";
|
||||
import { getAddresseId, getUserIdOfMailbox } from "../../db/utils/mail";
|
||||
// todo esbuild
|
||||
// todo mock db
|
||||
|
||||
// new message from us
|
||||
// to multiple people -> room
|
||||
// if response has same member => group
|
||||
@@ -20,13 +27,12 @@ import { getAddresseId, getUserIdOfMailbox } from "../../db/utils/mail";
|
||||
// // make it better
|
||||
// if multiple members reply -> group
|
||||
// if only me reply -> channel
|
||||
|
||||
const users = generateUsers(5);
|
||||
const ownUser = users[0];
|
||||
const messageId = 1;
|
||||
const boxId = 1;
|
||||
|
||||
jest.mock("../../db/mail", () => ({
|
||||
jest.mock("../../db/utils/mail", () => ({
|
||||
getAddresseId: jest.fn().mockImplementation((email) => {
|
||||
const match = users.find((user) => user.user.mailbox + "@" + user.user.host == email);
|
||||
return new Promise((resolve, reject) => resolve(match?.id));
|
||||
@@ -36,6 +42,10 @@ jest.mock("../../db/mail", () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
beforeAll(async () => {
|
||||
|
||||
});
|
||||
|
||||
describe("saveMessage", () => {
|
||||
describe("functions", () => {
|
||||
it("isFromUs", async () => {
|
||||
|
||||
Reference in New Issue
Block a user