2022-02-04 03:12:00 +00:00
|
|
|
import WakuMock, { Message } from "./WakuMock";
|
2021-04-16 01:32:00 +00:00
|
|
|
|
2022-02-04 03:12:00 +00:00
|
|
|
test("Messages are emitted", async () => {
|
2021-04-16 01:32:00 +00:00
|
|
|
const wakuMock = await WakuMock.create();
|
|
|
|
|
|
|
|
let message: Message;
|
2022-02-04 03:12:00 +00:00
|
|
|
wakuMock.on("message", (msg) => {
|
2021-04-16 01:32:00 +00:00
|
|
|
message = msg;
|
|
|
|
});
|
|
|
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
|
|
// @ts-ignore
|
|
|
|
expect(message.message).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2022-02-04 03:12:00 +00:00
|
|
|
test("Messages are sent", async () => {
|
2021-04-16 01:32:00 +00:00
|
|
|
const wakuMock = await WakuMock.create();
|
|
|
|
|
2022-02-04 03:12:00 +00:00
|
|
|
const text = "This is a message.";
|
2021-04-16 01:32:00 +00:00
|
|
|
|
|
|
|
let message: Message;
|
2022-02-04 03:12:00 +00:00
|
|
|
wakuMock.on("message", (msg) => {
|
2021-04-16 01:32:00 +00:00
|
|
|
message = msg;
|
|
|
|
});
|
|
|
|
|
|
|
|
await wakuMock.send(text);
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
expect(message.message).toEqual(text);
|
|
|
|
});
|