import { tap, expect } from '@push.rocks/tapbundle'; import { SmartacmeCertMatcher } from '../ts/smartacme.classes.certmatcher.js'; tap.test('should match 2-level domain', async () => { const matcher = new SmartacmeCertMatcher(); expect(matcher.getCertificateDomainNameByDomainName('example.com')).toEqual('example.com'); }); tap.test('should match 3-level domain', async () => { const matcher = new SmartacmeCertMatcher(); expect(matcher.getCertificateDomainNameByDomainName('subdomain.example.com')).toEqual('example.com'); }); tap.test('should return undefined for deeper domain', async () => { const matcher = new SmartacmeCertMatcher(); // domain with 4 or more levels const result = matcher.getCertificateDomainNameByDomainName('a.b.example.com'); expect(result).toEqual(undefined); }); // Wildcard domain handling tap.test('should strip wildcard prefix and return base domain', async () => { const matcher = new SmartacmeCertMatcher(); expect(matcher.getCertificateDomainNameByDomainName('*.example.com')).toEqual('example.com'); expect(matcher.getCertificateDomainNameByDomainName('*.sub.example.com')).toEqual('sub.example.com'); expect(matcher.getCertificateDomainNameByDomainName('*.a.b.example.com')).toEqual('a.b.example.com'); }); export default tap.start();