-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e58d04
commit d6b7576
Showing
3 changed files
with
58 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { strict as assert } from 'node:assert' | ||
import test from 'node:test' | ||
import { isIPv4 } from 'node:net' | ||
|
||
import { dnsRecordsCloudflare, dnsRecordsGoogle } from '../src/dns-resolvers.ts' | ||
|
||
test('Cloudflare DNS resolver - A', async () => { | ||
const aRecords = await dnsRecordsCloudflare('cloudflare.com', 'A') | ||
|
||
assert.notEqual(aRecords.length, 0) | ||
|
||
assert.equal(aRecords[0].name, 'cloudflare.com') | ||
assert.equal(aRecords[0].type, 'A') | ||
assert.ok(Number.isSafeInteger(aRecords[0].ttl)) | ||
assert.ok(isIPv4(aRecords[0].data)) | ||
}) | ||
|
||
test('Cloudflare DNS resolver - TXT', async () => { | ||
const txtRecords = await dnsRecordsCloudflare('cloudflare.com', 'txt') | ||
|
||
assert.notEqual(txtRecords.length, 0) | ||
|
||
assert.equal(txtRecords[0].name, 'cloudflare.com') | ||
assert.equal(txtRecords[0].type, 'TXT') | ||
assert.ok(Number.isSafeInteger(txtRecords[0].ttl)) | ||
assert.ok(txtRecords[0].data) | ||
}) | ||
|
||
test('Google DNS resolver - A', async () => { | ||
const aRecords = await dnsRecordsGoogle('google.com', 'A') | ||
|
||
console.log(aRecords) | ||
|
||
assert.notEqual(aRecords.length, 0) | ||
|
||
assert.equal(aRecords[0].name, 'google.com') | ||
assert.equal(aRecords[0].type, 'A') | ||
assert.ok(Number.isSafeInteger(aRecords[0].ttl)) | ||
assert.ok(isIPv4(aRecords[0].data)) | ||
}) | ||
|
||
test('Google DNS resolver - TXT', async () => { | ||
const txtRecords = await dnsRecordsGoogle('google.com', 'txt') | ||
|
||
assert.notEqual(txtRecords.length, 0) | ||
|
||
assert.equal(txtRecords[0].name, 'google.com') | ||
assert.equal(txtRecords[0].type, 'TXT') | ||
assert.ok(Number.isSafeInteger(txtRecords[0].ttl)) | ||
assert.ok(txtRecords[0].data) | ||
}) |