-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: kickstart domain-check repository
- Loading branch information
Showing
4 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
import { whois } from "./domainExpirationDate.js"; | ||
import { resolveMxRecords } from "./unregisteredMxRecords.js"; | ||
|
||
export async function main(domain) { | ||
if (!domain) { | ||
throw new Error("Domain is required"); | ||
} | ||
export { | ||
whois, | ||
resolveMxRecords | ||
}; | ||
|
||
const domainExpirationDate = await whois(domain); | ||
const mxRecordsUnregistered = await resolveMxRecords(domain); | ||
|
||
return { | ||
domainExpirationDate, | ||
mxRecordsUnregistered | ||
}; | ||
} | ||
|
||
main().catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
// Import Third-party Dependencies | ||
import test from "tape"; | ||
|
||
test("should pass", (t) => { | ||
t.pass(); | ||
// Import Internal Dependencies | ||
import { whois, resolveMxRecords } from "../src/index.js"; | ||
|
||
// MX OK | ||
test("Given a valid domain, this test should pass", async(t) => { | ||
// Given | ||
const domain = "google.com"; | ||
|
||
// When | ||
const mxRecords = await resolveMxRecords(domain); | ||
|
||
// Then | ||
t.equal(mxRecords[0], "smtp.google.com"); | ||
t.end(); | ||
}); | ||
|
||
// MX KO | ||
test("Given an invalid domain, this test should not pass", async(t) => { | ||
// Given | ||
const domain = "aaa"; | ||
|
||
// When | ||
const mxRecords = await resolveMxRecords(domain); | ||
|
||
// Then | ||
t.equal(mxRecords.error, `queryMx ENODATA ${domain}`); | ||
t.end(); | ||
}); | ||
|
||
// Socket | ||
test("Given a valid domain, this test should pass", async(t) => { | ||
// Given | ||
const domain = "google.com"; | ||
|
||
// When | ||
const domainExpirationDate = await whois(domain); | ||
|
||
// Then | ||
t.isNot(domainExpirationDate, ""); | ||
t.end(); | ||
}); |