24 lines
972 B
TypeScript
24 lines
972 B
TypeScript
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
import { extractDomain } from "./extract-domain.js";
|
|
|
|
describe("extractDomain", () => {
|
|
it("strips port and drops the images. subdomain", { timeout: 5000 }, () => {
|
|
expect(extractDomain("images.example.com:8080")).toBe("example.com");
|
|
expect(extractDomain("images.example.com")).toBe("example.com");
|
|
});
|
|
|
|
it("returns hosts without images. unchanged", { timeout: 5000 }, () => {
|
|
expect(extractDomain("example.com")).toBe("example.com");
|
|
expect(extractDomain("cdn.example.com")).toBe("cdn.example.com");
|
|
});
|
|
|
|
it("returns short hosts unchanged", { timeout: 5000 }, () => {
|
|
expect(extractDomain("localhost")).toBe("localhost");
|
|
expect(extractDomain("localhost:8080")).toBe("localhost");
|
|
});
|
|
|
|
it("handles images. with two-label host", { timeout: 5000 }, () => {
|
|
expect(extractDomain("images.co.uk")).toBe("co.uk");
|
|
});
|
|
});
|