-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Expand file tree
/
Copy pathspf-parse-tests.ts
More file actions
26 lines (21 loc) · 923 Bytes
/
spf-parse-tests.ts
File metadata and controls
26 lines (21 loc) · 923 Bytes
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
import spfParse = require("spf-parse");
const result = spfParse("v=spf1 a mx -all"); // $ExpectType ParseResult
result.mechanisms; // $ExpectType Mechanism[]
result.valid; // $ExpectType boolean
for (const mech of result.mechanisms) {
mech.type; // $ExpectType string
mech.value; // $ExpectType string | undefined
mech.prefix; // $ExpectType Prefix
mech.prefixdesc; // $ExpectType string | undefined
mech.description; // $ExpectType string | undefined
}
if (result.messages) {
for (const msg of result.messages) {
msg.message; // $ExpectType string
msg.type; // $ ExpectType "error" | "warning"
}
}
const messages: spfParse.ParseMessage[] = [];
const mech = spfParse.parseTerm("ip4:192.0.2.0/24", messages); // $ExpectType Mechanism
const err = new spfParse.MechanismError("invalid mech", "error"); // $ExpectType MechanismError
err.type; // $ExpectType "warning" | "error"