tests to mysql (not working)
This commit is contained in:
parent
49e8ec64e0
commit
8cc738c9b2
48
back/test/db/api-tes.ts
Normal file
48
back/test/db/api-tes.ts
Normal file
@ -0,0 +1,48 @@
|
||||
process.env.NODE_ENV = "test";
|
||||
import { jest, describe, it, expect } from "@jest/globals";
|
||||
import { execQueryAsync, execQuery } from "../../db/db";
|
||||
import { createRoom, registerMessageInRoom } from "../../db/message/saveMessage-db";
|
||||
import { registerFlag, registerMessage } from "../../db/message/storeMessage-db";
|
||||
import { getFlagId } from "../../db/utils/mail";
|
||||
import { RoomType } from "../../mails/message/saveMessage";
|
||||
|
||||
|
||||
beforeAll(async () => {
|
||||
console.log(await execQueryAsync(`SHOW TABLES`, []));
|
||||
// mocked(incrementNotSeenRoom).mockImplementation(db.incrementNotSeenRoom);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
const query = "SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE table_schema = 'mail_test'";
|
||||
execQueryAsync(query, []).then((results) => {
|
||||
execQuery("SET FOREIGN_KEY_CHECKS=0", []);
|
||||
results.map((table) => {
|
||||
execQuery("DELETE FROM " + table.table_name, []);
|
||||
// execQuery("DROP TABLE " + table.table_name);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const insertMessageWithFlag = async (flags: string[]): Promise<number> => {
|
||||
const messageId = await registerMessage("", 0, "");
|
||||
flags.forEach(async (flag) => {
|
||||
const flagId = await getFlagId(flag);
|
||||
await registerFlag(messageId, flagId);
|
||||
});
|
||||
return messageId;
|
||||
}
|
||||
|
||||
describe("api-db", () => {
|
||||
it.only("should count the number of unseen message in a room", async () => {
|
||||
const msgIdSeen = await insertMessageWithFlag(["\\\\Seen"]);
|
||||
const msgIdNotSeen = await insertMessageWithFlag([]);
|
||||
const msgIdNotSeen2 = await insertMessageWithFlag([]);
|
||||
const roomId = await createRoom("roomName", 0, msgIdSeen, RoomType.ROOM);
|
||||
await registerMessageInRoom(msgIdSeen, roomId, "");
|
||||
await registerMessageInRoom(msgIdNotSeen, roomId, "");
|
||||
await registerMessageInRoom(msgIdNotSeen2, roomId, "");
|
||||
|
||||
const res =
|
||||
expect()
|
||||
})
|
||||
});
|
@ -107,7 +107,7 @@ const classes = (): string => {
|
||||
</div>
|
||||
<div class="content" :class="[classes()]">
|
||||
<iframe ref="iframe"></iframe>
|
||||
<div class="options">options</div>
|
||||
<div class="options">options {{ props?.msg?.flags }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user