-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ts
executable file
·63 lines (56 loc) · 1.55 KB
/
test.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {
assertEquals,
assertStrictEq,
assert,
} from "https://deno.land/std/testing/asserts.ts";
import {
sendMail,
IRequestBody,
sendSimpleMail,
ISimpleRequestBody,
} from "./mod.ts";
// This is a throwaway key for testing a limited number of emails only,
// from a throwaway account. Sorta like giving you my keys, but the keys
// are to an outhouse.
const key =
"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";
Deno.test({
name: "Testing Simple Email",
async fn(): Promise<void> {
let response = await sendSimpleMail(
{
subject: "Hello world",
to: [{ email: "[email protected]" }],
from: { email: "[email protected]" },
content: [
{ type: "text/plain", value: "Hello world" },
{ type: "text/html", value: "<h1>Hello world</h1>" },
],
},
{ apiKey: key },
);
console.log(response);
assertEquals(response.success, true);
},
});
Deno.test({
name: "Testing Full Email",
async fn(): Promise<void> {
let mail: IRequestBody = {
personalizations: [
{
subject: "Hello world",
to: [{ name: "DenoTest2020", email: "[email protected]" }],
},
],
from: { email: "[email protected]" },
content: [
{ type: "text/plain", value: "Hello world" },
{ type: "text/html", value: "<h1>Hello world</h1>" },
],
};
let response = await sendMail(mail, { apiKey: key });
console.log(response);
assertEquals(response.success, true);
},
});