fix(whois): improve type safety and harden WHOIS parsing for missing fields
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartwhois from '../ts/index.js';
|
||||
|
||||
let testSmartWhois: smartwhois.SmartWhois;
|
||||
|
||||
tap.test('should create a valid instance of SmartWhois', async () => {
|
||||
testSmartWhois = new smartwhois.SmartWhois();
|
||||
expect(testSmartWhois).toBeInstanceOf(smartwhois.SmartWhois);
|
||||
});
|
||||
|
||||
tap.test('should get a parsed url result for whois', async () => {
|
||||
const domainDelegation = await testSmartWhois.getDomainDelegation('https://coffee.link/understanding-gen-z/');
|
||||
console.log(domainDelegation);
|
||||
const parsedUrlResult2 = await testSmartWhois.getDomainDelegation('task.vc');
|
||||
console.log(parsedUrlResult2);
|
||||
});
|
||||
|
||||
tap.test('should get additional data', async () => {
|
||||
const parsedUrlResult = await testSmartWhois.getAdditionalWhoisDataForDomain('https://coffee.link/understanding-gen-z/');
|
||||
console.log(parsedUrlResult);
|
||||
});
|
||||
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('task.vc');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('https://lossless.com');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('https://coffee.link/understanding-gen-z/');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
|
||||
tap.test('should check for a valid tld', async () => {
|
||||
const comIsValid = await testSmartWhois.isValidTld('.com');
|
||||
console.log(comIsValid);
|
||||
expect(comIsValid).toBeTrue();
|
||||
});
|
||||
|
||||
export default tap.start({
|
||||
throwOnError: true
|
||||
});
|
||||
Reference in New Issue
Block a user