|
| 1 | +import { describe, test, expect } from "@jest/globals"; |
| 2 | + |
| 3 | +import { extractCname } from "./cname"; |
| 4 | + |
| 5 | +describe("extractCname from ordinary domains", () => { |
| 6 | + test('should return "@" for top level like domains', () => { |
| 7 | + expect(extractCname("example")).toBe("@"); |
| 8 | + }); |
| 9 | + |
| 10 | + test('should return "@" for root level domains', () => { |
| 11 | + expect(extractCname("example.com")).toBe("@"); |
| 12 | + }); |
| 13 | + |
| 14 | + test("should return the subdomain", () => { |
| 15 | + expect(extractCname("sub.example.com")).toBe("sub"); |
| 16 | + }); |
| 17 | + |
| 18 | + test("should return all subdomains", () => { |
| 19 | + expect(extractCname("sub.sub.example.com")).toBe("sub.sub"); |
| 20 | + }); |
| 21 | +}); |
| 22 | + |
| 23 | +describe("extractCname from public suffix domains", () => { |
| 24 | + test('should return "@"', () => { |
| 25 | + expect(extractCname("co.za")).toBe("@"); |
| 26 | + }); |
| 27 | + |
| 28 | + test('should return "@"', () => { |
| 29 | + expect(extractCname("example.co.za")).toBe("@"); |
| 30 | + }); |
| 31 | + |
| 32 | + test("should return all the subdomain", () => { |
| 33 | + expect(extractCname("sub.example.co.za")).toBe("sub"); |
| 34 | + }); |
| 35 | + |
| 36 | + test("should handle domains with multiple public suffixes correctly", () => { |
| 37 | + expect(extractCname("sub.sub.example.co.za")).toBe("sub.sub"); |
| 38 | + }); |
| 39 | +}); |
0 commit comments