Files
OpenFlare/frontend/tests/zone/resolve-zone-domain-input.test.ts
T
2026-07-13 15:10:28 +08:00

35 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { resolveZoneDomainInput } from '@/app/(main)/websites/components/resolve-zone-domain-input';
describe('resolveZoneDomainInput', () => {
it('maps short label and apex @ under zone root', () => {
expect(resolveZoneDomainInput('api', 'example.com')).toEqual({
domain: 'api.example.com',
});
expect(resolveZoneDomainInput('@', 'example.com')).toEqual({
domain: 'example.com',
});
});
it('accepts full FQDN under the zone', () => {
expect(
resolveZoneDomainInput('www.api.example.com', 'example.com'),
).toEqual({
domain: 'www.api.example.com',
});
expect(resolveZoneDomainInput('example.com', 'example.com')).toEqual({
domain: 'example.com',
});
});
it('rejects foreign domains and wildcards', () => {
expect(
resolveZoneDomainInput('evil.com', 'example.com').error,
).toBeTruthy();
expect(
resolveZoneDomainInput('*.example.com', 'example.com').error,
).toBeTruthy();
});
});