Spaces:
Sleeping
Sleeping
File size: 1,765 Bytes
097eaf0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { generateDomainSplits } from "../../services/index";
describe("generateDomainSplits", () => {
it("should return original domain splits when no fake domain provided", () => {
const result = generateDomainSplits("example.com");
expect(result).toEqual(["example.com"]);
});
it("should return fake domain when provided without subdomains", () => {
const result = generateDomainSplits("example.com", "fake.com");
expect(result).toEqual(["fake.com"]);
});
it("should apply same splitting logic to fake domain with subdomains", () => {
const result = generateDomainSplits("sub.example.com", "api.fake.com");
expect(result).toEqual(["fake.com", "api.fake.com"]);
});
it("should apply splitting logic to fake domain with multiple subdomains", () => {
const result = generateDomainSplits("a.b.example.com", "x.y.fake.org");
expect(result).toEqual(["fake.org", "y.fake.org", "x.y.fake.org"]);
});
it("should handle www subdomain in fake domain correctly", () => {
const result = generateDomainSplits("www.example.com", "www.fake.com");
expect(result).toEqual(["fake.com"]);
});
it("should return fake domain when original hostname is invalid", () => {
const result = generateDomainSplits("invalid", "fake.com");
expect(result).toEqual(["fake.com"]);
});
it("should return fake domain when fake domain is invalid", () => {
const result = generateDomainSplits("example.com", "invalid");
expect(result).toEqual(["invalid"]);
});
it("should handle complex subdomain structures with fake domain", () => {
const result = generateDomainSplits(
"api.v1.service.example.com",
"sub.test.org",
);
expect(result).toEqual(["test.org", "sub.test.org"]);
});
});
|