-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathtests.js
48 lines (33 loc) · 1.04 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import test from "node:test";
import Mailjs from "./dist/mailjs.mjs";
const mailjs = new Mailjs();
test("Get a domain, create an account and log in.", async () => {
const { status, message } = await mailjs.createOneAccount();
if (!status) throw message;
});
test("Get account data.", async () => {
const { status, message } = await mailjs.me();
if (!status) throw message;
});
test("List messages.", async () => {
const { status, message } = await mailjs.getMessages();
if (!status) throw message;
});
test("Log in with JWT token.", async () => {
const token = mailjs.token;
const { status, message } = await mailjs.loginWithToken(token);
if(!status) throw message;
});
test("Test listener.", (_, done) => {
const onOpen = () => {
mailjs.off();
done();
};
const onError = err => done(err);
mailjs.on("open", onOpen);
mailjs.on("error", onError);
});
test("Delete account.", async () => {
const { status, message } = await mailjs.deleteMe();
if (!status) throw message;
});