Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolveAssetBase } from "./assetCdnBase";
|
||||
|
||||
describe("resolveAssetBase", () => {
|
||||
it("returns '/' when ASSET_CDN_URL is unset", () => {
|
||||
expect(resolveAssetBase({}, "production")).toBe("/");
|
||||
});
|
||||
|
||||
it("returns '/' when ASSET_CDN_URL is empty or whitespace", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "" }, "production")).toBe("/");
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: " " }, "production")).toBe("/");
|
||||
});
|
||||
|
||||
it("returns '/' in development regardless of ASSET_CDN_URL (HMR / dev server)", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com" }, "development")).toBe("/");
|
||||
});
|
||||
|
||||
it("returns origin with trailing slash for a valid https URL", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.boiler.saas-ctrl.com" }, "production")).toBe(
|
||||
"https://cdn.boiler.saas-ctrl.com/"
|
||||
);
|
||||
});
|
||||
|
||||
it("normalises trailing-slash variants to the same value", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com/" }, "production")).toBe(
|
||||
"https://cdn.example.com/"
|
||||
);
|
||||
});
|
||||
|
||||
it("strips paths from the CDN URL so vite controls the asset subdirectory", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com/some/path" }, "production")).toBe(
|
||||
"https://cdn.example.com/"
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to '/' for malformed URLs", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "not-a-url" }, "production")).toBe("/");
|
||||
});
|
||||
|
||||
it("treats an absent mode as non-development", () => {
|
||||
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com" })).toBe("https://cdn.example.com/");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user