smartstring/test/test.domain.both.ts

38 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2022-03-18 21:50:24 +00:00
import * as smartstring from '../ts/index.js';
2023-08-18 11:12:25 +00:00
import { tap, expect } from '@push.rocks/tapbundle';
2017-10-05 13:55:59 +00:00
// Domain
let testDomain: smartstring.Domain;
let testDomain2: smartstring.Domain;
2017-10-05 13:55:59 +00:00
tap.test('expect create a new Domain object', async () => {
testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
2022-03-18 21:50:24 +00:00
expect(testDomain).toBeInstanceOf(smartstring.Domain);
console.log(testDomain);
});
2017-10-05 13:55:59 +00:00
tap.test('expect have a .topLevel', async () => {
2022-03-18 21:50:24 +00:00
expect(testDomain.topLevel).toEqual('level1D');
});
2017-10-05 13:55:59 +00:00
tap.test('expect have a .level2', async () => {
2022-03-18 21:50:24 +00:00
expect(testDomain.level2).toEqual('level2D');
});
2017-10-05 13:55:59 +00:00
tap.test('expect have a .level3', async () => {
2022-03-18 21:50:24 +00:00
expect(testDomain.level3).toEqual('level3D');
});
2017-10-05 13:55:59 +00:00
tap.test('expect have the correct dns zone name', async () => {
2022-03-18 21:50:24 +00:00
expect(testDomain.zoneName).toEqual('level2D.level1D');
});
2017-10-05 13:55:59 +00:00
tap.test('expect have the correct protocol', async () => {
2022-03-18 21:50:24 +00:00
expect(testDomain.protocol).toEqual('https');
});
2017-10-05 13:55:59 +00:00
tap.test('testDomain2 expect be a basic domain', async () => {
2021-01-22 18:27:50 +00:00
testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
2017-10-05 13:55:59 +00:00
2021-01-22 14:46:02 +00:00
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2);
});
tap.start();